summary refs log tree commit diff
path: root/synapse/handlers/sliding_sync/extensions.py
diff options
context:
space:
mode:
authorErik Johnston <erikj@element.io>2024-09-30 12:58:02 +0100
committerGitHub <noreply@github.com>2024-09-30 12:58:02 +0100
commitece66ba61c3e2fe5b968ac564ea4d9019ddc7c70 (patch)
treeb15a217f705776622702b154c11c406b22b48e79 /synapse/handlers/sliding_sync/extensions.py
parentMerge branch 'release-v1.116' into develop (diff)
downloadsynapse-ece66ba61c3e2fe5b968ac564ea4d9019ddc7c70.tar.xz
Minor perf speed up for large accounts on SSS (#17751)
This works as instead of passing *all* rooms to `record_sent_rooms` we
only need to pass rooms that were previously not in the LIVE state.

This came from a py-spy where we were spending ~10% CPU calling these
functions. Note that `record_sent_rooms` is a no-op for rooms that are
already in the `LIVE` state, so we only need to call them for
`PREVIOUSLY` or `INITIAL` rooms.
Diffstat (limited to 'synapse/handlers/sliding_sync/extensions.py')
-rw-r--r--synapse/handlers/sliding_sync/extensions.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/synapse/handlers/sliding_sync/extensions.py b/synapse/handlers/sliding_sync/extensions.py

index 56e1d9329e..0c77b52513 100644 --- a/synapse/handlers/sliding_sync/extensions.py +++ b/synapse/handlers/sliding_sync/extensions.py
@@ -572,7 +572,8 @@ class SlidingSyncExtensionHandler: # Now record which rooms are now up to data, and which rooms have # pending updates to send. - new_connection_state.account_data.record_sent_rooms(relevant_room_ids) + new_connection_state.account_data.record_sent_rooms(previously_rooms.keys()) + new_connection_state.account_data.record_sent_rooms(initial_rooms) missing_updates = ( all_updates_since_the_from_token.keys() - relevant_room_ids ) @@ -763,9 +764,10 @@ class SlidingSyncExtensionHandler: room_id_to_receipt_map[room_id] = {"type": type, "content": content} - # Now we update the per-connection state to track which receipts we have - # and haven't sent down. - new_connection_state.receipts.record_sent_rooms(relevant_room_ids) + # Update the per-connection state to track which rooms we have sent + # all the receipts for. + new_connection_state.receipts.record_sent_rooms(previously_rooms.keys()) + new_connection_state.receipts.record_sent_rooms(initial_rooms) if from_token: # Now find the set of rooms that may have receipts that we're not sending