summary refs log tree commit diff
path: root/synapse/metrics
diff options
context:
space:
mode:
authorVincent Breitmoser <look@my.amazin.horse>2018-01-08 01:53:32 +0100
committerVincent Breitmoser <look@my.amazin.horse>2018-04-10 11:35:34 +0200
commit6d7f0f8dd3685b7d2c58a43662eb793defc186ff (patch)
tree7aa67b79485d226e69c3c24d01b9b17ff8ccade5 /synapse/metrics
parentIn DomainSpecificString, override __repr__ in addition to __str__ (diff)
downloadsynapse-6d7f0f8dd3685b7d2c58a43662eb793defc186ff.tar.xz
Don't disable GC when running on PyPy
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 <look@my.amazin.horse>
Diffstat (limited to 'synapse/metrics')
-rw-r--r--synapse/metrics/__init__.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/synapse/metrics/__init__.py b/synapse/metrics/__init__.py
index 50d99d7a5c..2ed82b04a5 100644
--- a/synapse/metrics/__init__.py
+++ b/synapse/metrics/__init__.py
@@ -17,6 +17,7 @@ import logging
 import functools
 import time
 import gc
+import platform
 
 from twisted.internet import reactor
 
@@ -30,6 +31,7 @@ from .process_collector import register_process_collector
 logger = logging.getLogger(__name__)
 
 
+running_on_pypy = platform.python_implementation() == 'PyPy'
 all_metrics = []
 all_collectors = []
 
@@ -174,6 +176,9 @@ def runUntilCurrentTimer(func):
         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()
@@ -206,6 +211,7 @@ try:
 
     # 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