Skip to content

Commit 1fa1f9b

Browse files
committed
Add max_entries=100 rationale
1 parent b4aa726 commit 1fa1f9b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

synapse/storage/databases/main/thread_subscriptions.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,21 @@ async def get_subscription_for_thread(
461461

462462
return ThreadSubscription(automatic=automatic)
463463

464+
# max_entries=100 rationale:
465+
# this returns a potentially large datastructure
466+
# (since each entry contains a set which contains a potentially large number of user IDs),
467+
# whereas the default of 10'000 entries for @cached feels more
468+
# suitable for very small cache entries.
469+
#
470+
# Overall, when bearing in mind the usual profile of a small community-server or company-server
471+
# (where cache tuning hasn't been done, so we're in out-of-box configuration), it is very
472+
# unlikely we would benefit from keeping hot the subscribers for as many as 100 threads,
473+
# since it's unlikely that so many threads will be active in a short span of time on a small homeserver.
474+
# It feels that medium servers will probably also not exhaust this limit.
475+
# Larger homeservers are more likely to be carefully tuned, either with a larger global cache factor
476+
# or carefully following the usage patterns & cache metrics.
477+
# Finally, the query is not so intensive that computing it every time is a huge deal, but given people
478+
# often send messages back-to-back in the same thread it seems like it would offer a mild benefit.
464479
@cached(max_entries=100)
465480
async def get_subscribers_to_thread(
466481
self, room_id: str, thread_root_event_id: str

0 commit comments

Comments
 (0)