summary refs log tree commit diff
path: root/synapse/app
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2020-02-19 15:09:00 +0000
committerGitHub <noreply@github.com>2020-02-19 15:09:00 +0000
commitfc87d2ffb39ca17065e19bd42ef25f1c84862d2c (patch)
treed1183f519412c5c5298b46758ce0daa8674e5785 /synapse/app
parentReduce auth chains fetched during v2 state res. (#6952) (diff)
downloadsynapse-fc87d2ffb39ca17065e19bd42ef25f1c84862d2c.tar.xz
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.
Diffstat (limited to 'synapse/app')
-rw-r--r--synapse/app/_base.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/synapse/app/_base.py b/synapse/app/_base.py
index 0e8b467a3e..109b1e2fb5 100644
--- a/synapse/app/_base.py
+++ b/synapse/app/_base.py
@@ -279,6 +279,15 @@ def start(hs, listeners=None):
 
         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()