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

Commit

Permalink
Change default sync_response_cache_duration (#13042)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston authored Jun 15, 2022
1 parent 7d99414 commit c95b04b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.d/13042.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Set default `sync_response_cache_duration` to two minutes.
6 changes: 6 additions & 0 deletions docker/complement/conf/workers-shared-extra.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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" %}
4 changes: 2 additions & 2 deletions docs/usage/configuration/config_documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion synapse/config/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:
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:
Expand Down
2 changes: 1 addition & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}],
}

Expand Down

0 comments on commit c95b04b

Please sign in to comment.