summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2021-05-04 14:23:02 +0100
committerErik Johnston <erik@matrix.org>2021-05-04 14:23:02 +0100
commitb5169b68e90fe494d0137e4676af929b85594a50 (patch)
tree9a2792b6349ec0a00f609e8694fa2689d4d25e81
parentConfig (diff)
downloadsynapse-b5169b68e90fe494d0137e4676af929b85594a50.tar.xz
Document default. Add type annotations. Correctly convert to seconds
-rw-r--r--docs/sample_config.yaml2
-rw-r--r--synapse/config/server.py15
-rw-r--r--synapse/metrics/__init__.py6
3 files changed, 14 insertions, 9 deletions
diff --git a/docs/sample_config.yaml b/docs/sample_config.yaml

index 94b28fecaf..a1dacefbd7 100644 --- a/docs/sample_config.yaml +++ b/docs/sample_config.yaml
@@ -158,6 +158,8 @@ presence: # A value of `[1s, 10s, 30s]` indicates that a second must pass between consecutive # generation 0 GCs, etc. # +# Defaults to `[1s, 10s, 30s]`. +# #gc_min_interval: [0.5s, 30s, 1m] # Set the limit on the returned events in the timeline in the get diff --git a/synapse/config/server.py b/synapse/config/server.py
index b639bd3144..c290a35a92 100644 --- a/synapse/config/server.py +++ b/synapse/config/server.py
@@ -19,7 +19,7 @@ import logging import os.path import re from textwrap import indent -from typing import Any, Dict, Iterable, List, Optional, Set +from typing import Any, Dict, Iterable, List, Optional, Set, Tuple import attr import yaml @@ -924,6 +924,8 @@ class ServerConfig(Config): # A value of `[1s, 10s, 30s]` indicates that a second must pass between consecutive # generation 0 GCs, etc. # + # Defaults to `[1s, 10s, 30s]`. + # #gc_min_interval: [0.5s, 30s, 1m] # Set the limit on the returned events in the timeline in the get @@ -1314,17 +1316,18 @@ class ServerConfig(Config): help="Turn on the twisted telnet manhole service on the given port.", ) - def read_gc_intervals(self, durations): - """Reads the three durations for the GC min interval option.""" + def read_gc_intervals(self, durations) -> Optional[Tuple[float, float, float]]: + """Reads the three durations for the GC min interval option, returning seconds.""" if durations is None: return None + try: if len(durations) != 3: raise ValueError() return ( - self.parse_duration(durations[0]), - self.parse_duration(durations[1]), - self.parse_duration(durations[2]), + self.parse_duration(durations[0]) / 1000, + self.parse_duration(durations[1]) / 1000, + self.parse_duration(durations[2]) / 1000, ) except Exception: raise ConfigError( diff --git a/synapse/metrics/__init__.py b/synapse/metrics/__init__.py
index 149ae3002a..e671da26d5 100644 --- a/synapse/metrics/__init__.py +++ b/synapse/metrics/__init__.py
@@ -537,10 +537,10 @@ REGISTRY.register(ReactorLastSeenMetric()) # The minimum time in seconds between GCs for each generation, regardless of the current GC # thresholds and counts. -MIN_TIME_BETWEEN_GCS = (1, 10, 30) +MIN_TIME_BETWEEN_GCS = (1.0, 10.0, 30.0) # The time (in seconds since the epoch) of the last time we did a GC for each generation. -_last_gc = [0, 0, 0] +_last_gc = [0.0, 0.0, 0.0] def runUntilCurrentTimer(reactor, func): @@ -601,7 +601,7 @@ def runUntilCurrentTimer(reactor, func): unreachable = gc.collect(i) end = time.time() - _last_gc[i] = int(end) + _last_gc[i] = end gc_time.labels(i).observe(end - start) gc_unreachable.labels(i).set(unreachable)