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

Add support for evicting cache entries based on last access time. #10205

Merged
merged 26 commits into from
Jul 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
700af7a
Add global cache list.
erikjohnston May 27, 2021
eaaee81
Add function to clean up old cache entries
erikjohnston Jun 18, 2021
811aa3f
Add config
erikjohnston Jun 18, 2021
9f62fdf
Newsfile
erikjohnston Jun 18, 2021
7ba719c
Update memory usage
erikjohnston Jun 18, 2021
01afcf6
Only use GLOBAL_LIST if time based eviction is enabled
erikjohnston Jun 18, 2021
a4657df
Add test
erikjohnston Jun 21, 2021
f72ed26
Reduce size overhead of new functionality
erikjohnston Jun 21, 2021
a52eb83
Merge remote-tracking branch 'origin/develop' into erikj/global_cache…
erikjohnston Jun 21, 2021
b314dfc
Fix 'caches' identation
erikjohnston Jun 24, 2021
6600a7c
Remove superflouous default None
erikjohnston Jun 24, 2021
e03a81c
Remove redundant setting of global_list_node
erikjohnston Jun 24, 2021
939ce8d
Make new attributes private
erikjohnston Jun 24, 2021
ecab588
Fixup comments
erikjohnston Jun 24, 2021
4181e1d
Improve comments and error handling when walking the graphs
erikjohnston Jun 24, 2021
7d865a1
Fix up names and comments in _expire_old_entries
erikjohnston Jun 24, 2021
be2667d
Add explicit `create_root_node`
erikjohnston Jun 24, 2021
1da43cb
Refactor so _ListNode doesn't take Clock
erikjohnston Jun 24, 2021
73064e0
Update comment about shared weakref
erikjohnston Jun 24, 2021
dd6dfdd
Remove superfluous _CacheEntry protocol
erikjohnston Jun 24, 2021
df40007
Add lock to ensure list mutation is thread safe
erikjohnston Jun 25, 2021
a2f5c11
Merge remote-tracking branch 'origin/develop' into erikj/global_cache…
erikjohnston Jul 5, 2021
df298d1
Fix indent
erikjohnston Jul 5, 2021
c5f19d9
Review comments
erikjohnston Jul 5, 2021
408e7c3
Move _ListNode to its own file
erikjohnston Jul 5, 2021
2f3480e
Apply suggestions from code review
erikjohnston Jul 5, 2021
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
56 changes: 28 additions & 28 deletions docs/sample_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -673,35 +673,35 @@ retention:
#event_cache_size: 10K

caches:
# Controls the global cache factor, which is the default cache factor
# for all caches if a specific factor for that cache is not otherwise
# set.
#
# This can also be set by the "SYNAPSE_CACHE_FACTOR" environment
# variable. Setting by environment variable takes priority over
# setting through the config file.
#
# Defaults to 0.5, which will half the size of all caches.
#
#global_factor: 1.0
# Controls the global cache factor, which is the default cache factor
# for all caches if a specific factor for that cache is not otherwise
# set.
#
# This can also be set by the "SYNAPSE_CACHE_FACTOR" environment
# variable. Setting by environment variable takes priority over
# setting through the config file.
#
# Defaults to 0.5, which will half the size of all caches.
#
#global_factor: 1.0

# A dictionary of cache name to cache factor for that individual
# cache. Overrides the global cache factor for a given cache.
#
# These can also be set through environment variables comprised
# of "SYNAPSE_CACHE_FACTOR_" + the name of the cache in capital
# letters and underscores. Setting by environment variable
# takes priority over setting through the config file.
# Ex. SYNAPSE_CACHE_FACTOR_GET_USERS_WHO_SHARE_ROOM_WITH_USER=2.0
#
# Some caches have '*' and other characters that are not
# alphanumeric or underscores. These caches can be named with or
# without the special characters stripped. For example, to specify
# the cache factor for `*stateGroupCache*` via an environment
# variable would be `SYNAPSE_CACHE_FACTOR_STATEGROUPCACHE=2.0`.
#
per_cache_factors:
#get_users_who_share_room_with_user: 2.0
# A dictionary of cache name to cache factor for that individual
# cache. Overrides the global cache factor for a given cache.
#
# These can also be set through environment variables comprised
# of "SYNAPSE_CACHE_FACTOR_" + the name of the cache in capital
# letters and underscores. Setting by environment variable
# takes priority over setting through the config file.
# Ex. SYNAPSE_CACHE_FACTOR_GET_USERS_WHO_SHARE_ROOM_WITH_USER=2.0
#
# Some caches have '*' and other characters that are not
# alphanumeric or underscores. These caches can be named with or
# without the special characters stripped. For example, to specify
# the cache factor for `*stateGroupCache*` via an environment
# variable would be `SYNAPSE_CACHE_FACTOR_STATEGROUPCACHE=2.0`.
#
per_cache_factors:
#get_users_who_share_room_with_user: 2.0

# Controls how long an entry can be in a cache without having been
# accessed before being evicted. Defaults to None, which means
Expand Down
58 changes: 29 additions & 29 deletions synapse/config/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,35 +116,35 @@ def generate_config_section(self, **kwargs):
#event_cache_size: 10K

caches:
# Controls the global cache factor, which is the default cache factor
# for all caches if a specific factor for that cache is not otherwise
# set.
#
# This can also be set by the "SYNAPSE_CACHE_FACTOR" environment
# variable. Setting by environment variable takes priority over
# setting through the config file.
#
# Defaults to 0.5, which will half the size of all caches.
#
#global_factor: 1.0

# A dictionary of cache name to cache factor for that individual
# cache. Overrides the global cache factor for a given cache.
#
# These can also be set through environment variables comprised
# of "SYNAPSE_CACHE_FACTOR_" + the name of the cache in capital
# letters and underscores. Setting by environment variable
# takes priority over setting through the config file.
# Ex. SYNAPSE_CACHE_FACTOR_GET_USERS_WHO_SHARE_ROOM_WITH_USER=2.0
#
# Some caches have '*' and other characters that are not
# alphanumeric or underscores. These caches can be named with or
# without the special characters stripped. For example, to specify
# the cache factor for `*stateGroupCache*` via an environment
# variable would be `SYNAPSE_CACHE_FACTOR_STATEGROUPCACHE=2.0`.
#
per_cache_factors:
#get_users_who_share_room_with_user: 2.0
# Controls the global cache factor, which is the default cache factor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style guide says "use two-space indents".

# for all caches if a specific factor for that cache is not otherwise
# set.
#
# This can also be set by the "SYNAPSE_CACHE_FACTOR" environment
# variable. Setting by environment variable takes priority over
# setting through the config file.
#
# Defaults to 0.5, which will half the size of all caches.
#
#global_factor: 1.0

# A dictionary of cache name to cache factor for that individual
# cache. Overrides the global cache factor for a given cache.
#
# These can also be set through environment variables comprised
# of "SYNAPSE_CACHE_FACTOR_" + the name of the cache in capital
# letters and underscores. Setting by environment variable
# takes priority over setting through the config file.
# Ex. SYNAPSE_CACHE_FACTOR_GET_USERS_WHO_SHARE_ROOM_WITH_USER=2.0
#
# Some caches have '*' and other characters that are not
# alphanumeric or underscores. These caches can be named with or
# without the special characters stripped. For example, to specify
# the cache factor for `*stateGroupCache*` via an environment
# variable would be `SYNAPSE_CACHE_FACTOR_STATEGROUPCACHE=2.0`.
#
per_cache_factors:
#get_users_who_share_room_with_user: 2.0

# Controls how long an entry can be in a cache without having been
# accessed before being evicted. Defaults to None, which means
Expand Down