summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2022-07-19 14:40:37 +0100
committerGitHub <noreply@github.com>2022-07-19 14:40:37 +0100
commitde70b25e844035c26a1bc40fbf6c8982e5d37b45 (patch)
tree106d0dd41ad13e6fb8eabc777319367c7d18cafc
parentStop building Ubuntu 21.10 (Impish Indri) which is end of life. (#13326) (diff)
downloadsynapse-de70b25e844035c26a1bc40fbf6c8982e5d37b45.tar.xz
Reduce memory usage of state group cache (#13323)
-rw-r--r--changelog.d/13323.misc1
-rw-r--r--synapse/storage/databases/state/bg_updates.py3
2 files changed, 3 insertions, 1 deletions
diff --git a/changelog.d/13323.misc b/changelog.d/13323.misc
new file mode 100644
index 0000000000..3caa94a2f6
--- /dev/null
+++ b/changelog.d/13323.misc
@@ -0,0 +1 @@
+Reduce memory usage of state caches.
diff --git a/synapse/storage/databases/state/bg_updates.py b/synapse/storage/databases/state/bg_updates.py
index fa9eadaca7..a7fcc564a9 100644
--- a/synapse/storage/databases/state/bg_updates.py
+++ b/synapse/storage/databases/state/bg_updates.py
@@ -24,6 +24,7 @@ from synapse.storage.database import (
 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
@@ -136,7 +137,7 @@ class StateGroupBackgroundUpdateStore(SQLBaseStore):
                 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))
                     results[group][key] = event_id
         else:
             max_entries_returned = state_filter.max_entries_returned()