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

Commit

Permalink
Don't disable GC when running on PyPy
Browse files Browse the repository at this point in the history
PyPy's incminimark GC can't be triggered manually. From what I observed
there are no obvious issues with just letting it run normally. And
unlike CPython, it actually returns unused RAM to the system.

Signed-off-by: Vincent Breitmoser <[email protected]>
  • Loading branch information
Valodim committed Apr 10, 2018
1 parent f4284d9 commit 6d7f0f8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion synapse/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import functools
import time
import gc
import platform

from twisted.internet import reactor

Expand All @@ -30,6 +31,7 @@
logger = logging.getLogger(__name__)


running_on_pypy = platform.python_implementation() == 'PyPy'
all_metrics = []
all_collectors = []

Expand Down Expand Up @@ -174,6 +176,9 @@ def f(*args, **kwargs):
tick_time.inc_by(end - start)
pending_calls_metric.inc_by(num_pending)

if running_on_pypy:
return ret

# Check if we need to do a manual GC (since its been disabled), and do
# one if necessary.
threshold = gc.get_threshold()
Expand Down Expand Up @@ -206,6 +211,7 @@ def f(*args, **kwargs):

# We manually run the GC each reactor tick so that we can get some metrics
# about time spent doing GC,
gc.disable()
if not running_on_pypy:
gc.disable()
except AttributeError:
pass

0 comments on commit 6d7f0f8

Please sign in to comment.