Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Freeze allocated objects on startup. (#6953)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
erikjohnston committed Feb 19, 2020
1 parent 2b37eab commit fc87d2f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/6953.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reduce time spent doing GC by freezing objects on startup.
9 changes: 9 additions & 0 deletions synapse/app/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,15 @@ def handle_sighup(*args, **kwargs):

setup_sentry(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:
traceback.print_exc(file=sys.stderr)
reactor = hs.get_reactor()
Expand Down

0 comments on commit fc87d2f

Please sign in to comment.