Skip to content

Commit

Permalink
Sliding Sync: Increase concurrency of sliding sync a bit (#17696)
Browse files Browse the repository at this point in the history
For initial requests a typical page size is 20 rooms, so we may as well
do the batching as 20.

This should speed up bigger syncs a little bit.
  • Loading branch information
erikjohnston committed Sep 12, 2024
1 parent 9b83fb7 commit 1cb84aa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/17696.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Speed up sliding sync requests a bit where there are many room changes.
2 changes: 1 addition & 1 deletion synapse/handlers/sliding_sync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ async def handle_room(room_id: str) -> None:

if relevant_rooms_to_send_map:
with start_active_span("sliding_sync.generate_room_entries"):
await concurrently_execute(handle_room, relevant_rooms_to_send_map, 10)
await concurrently_execute(handle_room, relevant_rooms_to_send_map, 20)

extensions = await self.extensions.get_extensions_response(
sync_config=sync_config,
Expand Down
10 changes: 9 additions & 1 deletion synapse/handlers/sliding_sync/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
SlidingSyncConfig,
SlidingSyncResult,
)
from synapse.util.async_helpers import concurrently_execute

if TYPE_CHECKING:
from synapse.server import HomeServer
Expand Down Expand Up @@ -534,7 +535,10 @@ async def get_receipts_extension_response(
# For rooms we've previously sent down, but aren't up to date, we
# need to use the from token from the room status.
if previously_rooms:
for room_id, receipt_token in previously_rooms.items():
# Fetch any missing rooms concurrently.

async def handle_previously_room(room_id: str) -> None:
receipt_token = previously_rooms[room_id]
# TODO: Limit the number of receipts we're about to send down
# for the room, if its too many we should TODO
previously_receipts = (
Expand All @@ -546,6 +550,10 @@ async def get_receipts_extension_response(
)
fetched_receipts.extend(previously_receipts)

await concurrently_execute(
handle_previously_room, previously_rooms.keys(), 20
)

if initial_rooms:
# We also always send down receipts for the current user.
user_receipts = (
Expand Down

0 comments on commit 1cb84aa

Please sign in to comment.