summary refs log tree commit diff
path: root/synapse/metrics
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-05-16 09:32:29 +0100
committerErik Johnston <erik@matrix.org>2016-05-16 09:34:42 +0100
commit60d53f9e9596520472954831ce8fea251a462d46 (patch)
treec00c4e587ef73a0a7339a0a2aa747a6a2dfd3829 /synapse/metrics
parentAdd a comment (diff)
downloadsynapse-60d53f9e9596520472954831ce8fea251a462d46.tar.xz
Count number of GC collects
Diffstat (limited to 'synapse/metrics')
-rw-r--r--synapse/metrics/__init__.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/synapse/metrics/__init__.py b/synapse/metrics/__init__.py
index c82685a524..bba2657075 100644
--- a/synapse/metrics/__init__.py
+++ b/synapse/metrics/__init__.py
@@ -156,7 +156,12 @@ get_metrics_for("process").register_callback("fds", _process_fds, labels=["type"
 reactor_metrics = get_metrics_for("reactor")
 tick_time = reactor_metrics.register_distribution("tick_time")
 pending_calls_metric = reactor_metrics.register_distribution("pending_calls")
-gc_time = reactor_metrics.register_distribution("gc_time")
+
+gc_time = (
+    reactor_metrics.register_distribution("gc_time_gen0"),
+    reactor_metrics.register_distribution("gc_time_gen2"),
+    reactor_metrics.register_distribution("gc_time_gen2"),
+)
 
 
 def runUntilCurrentTimer(func):
@@ -189,14 +194,15 @@ def runUntilCurrentTimer(func):
         # one if necessary.
         threshold = gc.get_threshold()
         counts = gc.get_count()
-
-        start = time.time() * 1000
         for i in [2, 1, 0]:
             if threshold[i] < counts[i]:
                 logger.info("Collecting gc %d", i)
+
+                start = time.time() * 1000
                 gc.collect(i)
-        end = time.time() * 1000
-        gc_time.inc_by(end - start)
+                end = time.time() * 1000
+
+                gc_time[i].inc_by(end - start)
 
         return ret