From c95b04bb0e719d3f5de1714b442f95a39c6e3634 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 15 Jun 2022 17:55:20 +0100 Subject: Change default `sync_response_cache_duration` (#13042) --- changelog.d/13042.misc | 1 + docker/complement/conf/workers-shared-extra.yaml.j2 | 6 ++++++ docs/usage/configuration/config_documentation.md | 4 ++-- synapse/config/cache.py | 2 +- tests/utils.py | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 changelog.d/13042.misc diff --git a/changelog.d/13042.misc b/changelog.d/13042.misc new file mode 100644 index 0000000000..745d5fcf84 --- /dev/null +++ b/changelog.d/13042.misc @@ -0,0 +1 @@ +Set default `sync_response_cache_duration` to two minutes. diff --git a/docker/complement/conf/workers-shared-extra.yaml.j2 b/docker/complement/conf/workers-shared-extra.yaml.j2 index a5b1b6bb8b..7c6a0fd756 100644 --- a/docker/complement/conf/workers-shared-extra.yaml.j2 +++ b/docker/complement/conf/workers-shared-extra.yaml.j2 @@ -103,4 +103,10 @@ server_notices: system_mxid_avatar_url: "" room_name: "Server Alert" + +# Disable sync cache so that initial `/sync` requests are up-to-date. +caches: + sync_response_cache_duration: 0 + + {% include "shared-orig.yaml.j2" %} diff --git a/docs/usage/configuration/config_documentation.md b/docs/usage/configuration/config_documentation.md index e88f68d2b8..4e68801938 100644 --- a/docs/usage/configuration/config_documentation.md +++ b/docs/usage/configuration/config_documentation.md @@ -1137,8 +1137,8 @@ Caching can be configured through the following sub-options: * `sync_response_cache_duration`: Controls how long the results of a /sync request are cached for after a successful response is returned. A higher duration can help clients with intermittent connections, at the cost of higher memory usage. - By default, this is zero, which means that sync responses are not cached - at all. + A value of zero means that sync responses are not cached. + Defaults to 2m. * `cache_autotuning` and its sub-options `max_cache_memory_usage`, `target_cache_memory_usage`, and `min_cache_ttl` work in conjunction with each other to maintain a balance between cache memory usage and cache entry availability. You must be using [jemalloc](https://github.com/matrix-org/synapse#help-synapse-is-slow-and-eats-all-my-ramcpu) diff --git a/synapse/config/cache.py b/synapse/config/cache.py index d0b491ea6c..63310c8d07 100644 --- a/synapse/config/cache.py +++ b/synapse/config/cache.py @@ -206,7 +206,7 @@ class CacheConfig(Config): self.cache_autotuning["min_cache_ttl"] = self.parse_duration(min_cache_ttl) self.sync_response_cache_duration = self.parse_duration( - cache_config.get("sync_response_cache_duration", 0) + cache_config.get("sync_response_cache_duration", "2m") ) def resize_all_caches(self) -> None: diff --git a/tests/utils.py b/tests/utils.py index 3059c453d5..cabb2c0dec 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -169,7 +169,7 @@ def default_config(name, parse=False): # disable user directory updates, because they get done in the # background, which upsets the test runner. "update_user_directory": False, - "caches": {"global_factor": 1}, + "caches": {"global_factor": 1, "sync_response_cache_duration": 0}, "listeners": [{"port": 0, "type": "http"}], } -- cgit 1.4.1