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

Commit

Permalink
Count number of GC collects
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed May 16, 2016
1 parent 7d6e89e commit 60d53f9
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions synapse/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,12 @@ def _process_fds():
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):
Expand Down Expand Up @@ -189,14 +194,15 @@ def f(*args, **kwargs):
# 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

Expand Down

0 comments on commit 60d53f9

Please sign in to comment.