1
0

Log if we ever gc.freeze() (#19440)

Spawning from
https://github.com/element-hq/synapse-small-hosts/issues/348 where some
test appears to be flaky because some homeserver objects are frozen in
the garbage collector.

We set
[`freeze=False`](a9a6869aa9/multi_synapse/app/shard.py (L319-L321))
in the [Synapse Pro for small
hosts](https://docs.element.io/latest/element-server-suite-pro/synapse-pro-for-small-hosts/overview/)
code but I just want to use this log to make extra sure this isn't being
run somehow. The follow-up here would be to see what else would cause
something to be frozen in the garbage collector.
This commit is contained in:
Eric Eastwood
2026-02-25 09:47:13 -06:00
committed by GitHub
parent bc15ed3c62
commit ac3a115511
2 changed files with 6 additions and 0 deletions

1
changelog.d/19440.misc Normal file
View File

@@ -0,0 +1 @@
Add log to explain when and why we freeze objects in the garbage collector.

View File

@@ -776,6 +776,11 @@ async def start(hs: "HomeServer", *, freeze: bool = True) -> None:
#
# PyPy does not (yet?) implement gc.freeze()
if hasattr(gc, "freeze"):
logger.info(
"garbage collector: Freezing all allocated objects in the hopes that (almost) "
"everything currently allocated are things that will be used by the homeserver "
"for the rest of time. Doing so means less work each GC (hopefully)."
)
gc.collect()
gc.freeze()