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

Commit 5172c8c

Browse files
reivilibreSean Quah
andauthored
Faster remote room joins (worker mode): do not populate external hosts-in-room cache when sending events as this requires blocking for full state. (#14749)
Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> Co-authored-by: Sean Quah <seanq@matrix.org>
1 parent 7f2cabf commit 5172c8c

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

changelog.d/14749.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Faster remote room joins (worker mode): do not populate external hosts-in-room cache when sending events as this requires blocking for full state.

synapse/handlers/message.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,12 +1531,23 @@ async def cache_joined_hosts_for_events(
15311531
external federation senders don't have to recalculate it themselves.
15321532
"""
15331533

1534-
for event, _ in events_and_context:
1535-
if not self._external_cache.is_enabled():
1536-
return
1534+
if not self._external_cache.is_enabled():
1535+
return
15371536

1538-
# If external cache is enabled we should always have this.
1539-
assert self._external_cache_joined_hosts_updates is not None
1537+
# If external cache is enabled we should always have this.
1538+
assert self._external_cache_joined_hosts_updates is not None
1539+
1540+
for event, event_context in events_and_context:
1541+
if event_context.partial_state:
1542+
# To populate the cache for a partial-state event, we either have to
1543+
# block until full state, which the code below does, or change the
1544+
# meaning of cache values to be the list of hosts to which we plan to
1545+
# send events and calculate that instead.
1546+
#
1547+
# The federation senders don't use the external cache when sending
1548+
# events in partial-state rooms anyway, so let's not bother populating
1549+
# the cache.
1550+
continue
15401551

15411552
# We actually store two mappings, event ID -> prev state group,
15421553
# state group -> joined hosts, which is much more space efficient

0 commit comments

Comments
 (0)