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

Commit 6fe749f

Browse files
committed
Optionally disable state groups caching
The theory behind this is that the overhead and high churn rate of the cache result in greater CPU and memory wastage than is offloaded from the database. Note this still caches groups on insert which means multiple room inserts in a short period (ie during room creation) will still benefit from the cache.
1 parent 756c0db commit 6fe749f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

synapse/storage/databases/state/store.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
import logging
16+
import os
1617
from typing import TYPE_CHECKING, Collection, Dict, Iterable, List, Optional, Set, Tuple
1718

1819
import attr
@@ -40,6 +41,10 @@
4041

4142
MAX_STATE_DELTA_HOPS = 100
4243

44+
BEEPER_DISABLE_STATE_GROUPS_CACHE = bool(
45+
os.environ.get("BEEPER_DISABLE_STATE_GROUPS_CACHE")
46+
)
47+
4348

4449
@attr.s(slots=True, frozen=True, auto_attribs=True)
4550
class _GetStateGroupDelta:
@@ -358,6 +363,9 @@ def _insert_into_cache(
358363
last lookup in cache
359364
"""
360365

366+
if BEEPER_DISABLE_STATE_GROUPS_CACHE:
367+
return
368+
361369
# We need to work out which types we've fetched from the DB for the
362370
# member vs non-member caches. This should be as accurate as possible,
363371
# but can be an underestimate (e.g. when we have wild cards)

0 commit comments

Comments
 (0)