File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -213,3 +213,21 @@ def configure_cors_middleware(app):
213
213
cors_options ["allow_origin_regex" ] = cmd_opts .cors_allow_origins_regex
214
214
app .add_middleware (CORSMiddleware , ** cors_options )
215
215
216
+
217
+ def preload_malloc ():
218
+ if os .name == 'nt' :
219
+ import ctypes
220
+ # under windows we can't use LD_PRELOAD method but still we can load the libtcmalloc_minimal.dll using ctypes.cdll
221
+ # https://github.com/gperftools/gperftools/ (only gperftools's tcmalloc works with windows)
222
+ # build libtcmalloc_minimal.dll patch module and copy it into the top dir of webui
223
+
224
+ dir_path = os .path .dirname (__file__ )
225
+ tcmallocdll = os .path .join (dir_path , ".." , "libtcmalloc_minimal.dll" )
226
+
227
+ if os .path .exists (tcmallocdll ):
228
+ # load libtcmalloc_minimal.dll if it exists.
229
+ _tcmalloc_dll = ctypes .cdll .LoadLibrary (tcmallocdll )
230
+
231
+ return 'tcmalloc'
232
+
233
+ return None
Original file line number Diff line number Diff line change 10
10
startup_timer = timer .startup_timer
11
11
startup_timer .record ("launcher" )
12
12
13
+ malloc = initialize_util .preload_malloc ()
14
+ if malloc is not None :
15
+ startup_timer .record (f"{ malloc } " )
16
+
13
17
initialize .imports ()
14
18
15
19
initialize .check_versions ()
You can’t perform that action at this time.
0 commit comments