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

Limit how often GC happens by time. #9902

Merged
merged 6 commits into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/sample_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ presence:
# The minimum time in seconds between each GC for a generation, regardless of
# the GC thresholds. This ensures that we don't do GC too frequently.
#
# A value of `[1, 10, 30]` indicates that a second must pass between consecutive
# A value of `[1s, 10s, 30s]` indicates that a second must pass between consecutive
# generation 0 GCs, etc.
#
# gc_min_seconds_between: [1, 10, 30]
#gc_min_interval: [0.5s, 30s, 1m]
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved

# Set the limit on the returned events in the timeline in the get
# and sync operations. The default value is 100. -1 means no upper limit.
Expand Down
23 changes: 20 additions & 3 deletions synapse/config/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ def read_config(self, config, **kwargs):
_warn_if_webclient_configured(self.listeners)

self.gc_thresholds = read_gc_thresholds(config.get("gc_thresholds", None))
self.gc_seconds = read_gc_thresholds(config.get("gc_min_seconds_between", None))
self.gc_seconds = self.read_gc_intervals(config.get("gc_min_interval", None))
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved

@attr.s
class LimitRemoteRoomsConfig:
Expand Down Expand Up @@ -921,10 +921,10 @@ def generate_config_section(
# The minimum time in seconds between each GC for a generation, regardless of
# the GC thresholds. This ensures that we don't do GC too frequently.
#
# A value of `[1, 10, 30]` indicates that a second must pass between consecutive
# A value of `[1s, 10s, 30s]` indicates that a second must pass between consecutive
# generation 0 GCs, etc.
#
# gc_min_seconds_between: [1, 10, 30]
#gc_min_interval: [0.5s, 30s, 1m]

# Set the limit on the returned events in the timeline in the get
# and sync operations. The default value is 100. -1 means no upper limit.
Expand Down Expand Up @@ -1314,6 +1314,23 @@ def add_arguments(parser):
help="Turn on the twisted telnet manhole service on the given port.",
)

def read_gc_intervals(self, durations):
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved
"""Reads the three durations for the GC min interval option."""
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]),
)
except Exception:
raise ConfigError(
"Value of `gc_min_interval` must be a list of three durations if set"
)


def is_threepid_reserved(reserved_threepids, threepid):
"""Check the threepid against the reserved threepid config
Expand Down
4 changes: 2 additions & 2 deletions synapse/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,9 @@ def collect(self):

# 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, 10, 30)

# The time in seconds of the last time we did a GC for each generation.
# The time (in seconds since the epoch) of the last time we did a GC for each generation.
_last_gc = [0, 0, 0]


Expand Down