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

Commit 2c6aae8

Browse files
committed
Freeze allocated objects on startup. (#6953)
* commit 'fc87d2ffb': Freeze allocated objects on startup. (#6953)
2 parents 8fbacc7 + fc87d2f commit 2c6aae8

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

changelog.d/6953.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Reduce time spent doing GC by freezing objects on startup.

synapse/app/_base.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,15 @@ def handle_sighup(*args, **kwargs):
279279

280280
setup_sentry(hs)
281281
setup_sdnotify(hs)
282+
283+
# We now freeze all allocated objects in the hopes that (almost)
284+
# everything currently allocated are things that will be used for the
285+
# rest of time. Doing so means less work each GC (hopefully).
286+
#
287+
# This only works on Python 3.7
288+
if sys.version_info >= (3, 7):
289+
gc.collect()
290+
gc.freeze()
282291
except Exception:
283292
traceback.print_exc(file=sys.stderr)
284293
reactor = hs.get_reactor()

0 commit comments

Comments
 (0)