mirror of
https://github.com/element-hq/synapse
synced 2024-08-19 04:30:53 +00:00
Freeze allocated objects on startup. (#6953)
This may make gc go a bit faster as the gc will know things like caches/data stores etc. are frozen without having to check.
This commit is contained in:
parent
2b37eabca1
commit
fc87d2ffb3
2 changed files with 10 additions and 0 deletions
1
changelog.d/6953.misc
Normal file
1
changelog.d/6953.misc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Reduce time spent doing GC by freezing objects on startup.
|
|
@ -279,6 +279,15 @@ def start(hs, listeners=None):
|
||||||
|
|
||||||
setup_sentry(hs)
|
setup_sentry(hs)
|
||||||
setup_sdnotify(hs)
|
setup_sdnotify(hs)
|
||||||
|
|
||||||
|
# We now freeze all allocated objects in the hopes that (almost)
|
||||||
|
# everything currently allocated are things that will be used for the
|
||||||
|
# rest of time. Doing so means less work each GC (hopefully).
|
||||||
|
#
|
||||||
|
# This only works on Python 3.7
|
||||||
|
if sys.version_info >= (3, 7):
|
||||||
|
gc.collect()
|
||||||
|
gc.freeze()
|
||||||
except Exception:
|
except Exception:
|
||||||
traceback.print_exc(file=sys.stderr)
|
traceback.print_exc(file=sys.stderr)
|
||||||
reactor = hs.get_reactor()
|
reactor = hs.get_reactor()
|
||||||
|
|
Loading…
Reference in a new issue