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

Reduce memory usage of state group cache #13323

Merged
merged 2 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions changelog.d/13323.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reduce memory usage of state caches.
3 changes: 2 additions & 1 deletion synapse/storage/databases/state/bg_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from synapse.storage.engines import PostgresEngine
from synapse.storage.state import StateFilter
from synapse.types import MutableStateMap, StateMap
from synapse.util.caches import intern_string

if TYPE_CHECKING:
from synapse.server import HomeServer
Expand Down Expand Up @@ -136,7 +137,7 @@ def _get_state_groups_from_groups_txn(
txn.execute(sql % (where_clause,), args)
for row in txn:
typ, state_key, event_id = row
key = (typ, state_key)
key = (intern_string(typ), intern_string(state_key))
Copy link
Member

Choose a reason for hiding this comment

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

I was confused why the background update matter, until I realized this method is also called from StateGroupDataStore. 😢

results[group][key] = event_id
else:
max_entries_returned = state_filter.max_entries_returned()
Expand Down