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

Commit

Permalink
Always cache 'event_to_prev_state_group'
Browse files Browse the repository at this point in the history
Fixes regression in send PDU times introduced in #9905.
  • Loading branch information
erikjohnston committed May 7, 2021
1 parent e11cd36 commit 7865bc1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelog.d/9950.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve performance of sending events for worker-based deployments using Redis.
13 changes: 7 additions & 6 deletions synapse/handlers/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -1050,19 +1050,20 @@ async def cache_joined_hosts_for_event(
)

if state_entry.state_group:
await self._external_cache.set(
"event_to_prev_state_group",
event.event_id,
state_entry.state_group,
expiry_ms=60 * 60 * 1000,
)

if state_entry.state_group in self._external_cache_joined_hosts_updates:
return

joined_hosts = await self.store.get_joined_hosts(event.room_id, state_entry)

# Note that the expiry times must be larger than the expiry time in
# _external_cache_joined_hosts_updates.
await self._external_cache.set(
"event_to_prev_state_group",
event.event_id,
state_entry.state_group,
expiry_ms=60 * 60 * 1000,
)
await self._external_cache.set(
"get_joined_hosts",
str(state_entry.state_group),
Expand Down

0 comments on commit 7865bc1

Please sign in to comment.