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

Commit

Permalink
If global_factor is omitted, use 0.5 on reload
Browse files Browse the repository at this point in the history
Consider the following scenario:

1. Start synapse with config that omits a `caches.global_factor`.
2. `CacheProperties.default_factor_size` is now 0.5.
3. Edit config to set `caches.global_factor = 2`.
4. Reload config.
5. Read `CacheProperties.default_factor_size`.
   - Without patch: still 2
   - With patch: backt to 0.5

Without this commit, when we reload config we will compute
`self.global_factor` to be the _previous_ global cache factor. I think
this is surprising: I would that factor to reflect what the config file
says.
  • Loading branch information
David Robertson committed May 9, 2022
1 parent 85f4385 commit 1febfd6
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions synapse/config/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:
self.cache_factors: Dict[str, float] = {}

cache_config = config.get("caches") or {}
self.global_factor = cache_config.get(
"global_factor", properties.default_factor_size
)
self.global_factor = cache_config.get("global_factor", _DEFAULT_FACTOR_SIZE)
if not isinstance(self.global_factor, (int, float)):
raise ConfigError("caches.global_factor must be a number.")

Expand Down

0 comments on commit 1febfd6

Please sign in to comment.