mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-04-10 14:59:00 +08:00
Merge 7a917228d69fd892eb3fc6602a4839ff50c39076 into 374bb6cc384d2a19422c0b07d69de0a41d1f3f4d
This commit is contained in:
commit
37c8680ae2
@ -213,3 +213,21 @@ def configure_cors_middleware(app):
|
|||||||
cors_options["allow_origin_regex"] = cmd_opts.cors_allow_origins_regex
|
cors_options["allow_origin_regex"] = cmd_opts.cors_allow_origins_regex
|
||||||
app.add_middleware(CORSMiddleware, **cors_options)
|
app.add_middleware(CORSMiddleware, **cors_options)
|
||||||
|
|
||||||
|
|
||||||
|
def preload_malloc():
|
||||||
|
if os.name == 'nt':
|
||||||
|
import ctypes
|
||||||
|
# under windows we can't use LD_PRELOAD method but still we can load the libtcmalloc_minimal.dll using ctypes.cdll
|
||||||
|
# https://github.com/gperftools/gperftools/ (only gperftools's tcmalloc works with windows)
|
||||||
|
# build libtcmalloc_minimal.dll patch module and copy it into the top dir of webui
|
||||||
|
|
||||||
|
dir_path = os.path.dirname(__file__)
|
||||||
|
tcmallocdll = os.path.join(dir_path, "..", "libtcmalloc_minimal.dll")
|
||||||
|
|
||||||
|
if os.path.exists(tcmallocdll):
|
||||||
|
# load libtcmalloc_minimal.dll if it exists.
|
||||||
|
_tcmalloc_dll = ctypes.cdll.LoadLibrary(tcmallocdll)
|
||||||
|
|
||||||
|
return 'tcmalloc'
|
||||||
|
|
||||||
|
return None
|
||||||
|
4
webui.py
4
webui.py
@ -10,6 +10,10 @@ from modules import initialize
|
|||||||
startup_timer = timer.startup_timer
|
startup_timer = timer.startup_timer
|
||||||
startup_timer.record("launcher")
|
startup_timer.record("launcher")
|
||||||
|
|
||||||
|
malloc = initialize_util.preload_malloc()
|
||||||
|
if malloc is not None:
|
||||||
|
startup_timer.record(f"{malloc}")
|
||||||
|
|
||||||
initialize.imports()
|
initialize.imports()
|
||||||
|
|
||||||
initialize.check_versions()
|
initialize.check_versions()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user