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

Commit 76aa553

Browse files
richvdhclokep
andauthored
Disable aggregation bundling on /sync responses (#11583)
* Disable aggregation bundling on `/sync` responses A partial revert of #11478. This turns out to have had a significant CPU impact on initial-sync handling. For now, let's disable it, until we find a more efficient way of achieving this. * Fix tests. Co-authored-by: Patrick Cloke <[email protected]>
1 parent 92906e1 commit 76aa553

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

changelog.d/11583.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a performance regression in `/sync` handling, introduced in 1.49.0.

synapse/rest/client/sync.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,15 @@ def serialize(events: Iterable[EventBase]) -> Awaitable[List[JsonDict]]:
522522
time_now=time_now,
523523
# Don't bother to bundle aggregations if the timeline is unlimited,
524524
# as clients will have all the necessary information.
525-
bundle_aggregations=room.timeline.limited,
525+
# bundle_aggregations=room.timeline.limited,
526+
#
527+
# richvdh 2021-12-15: disable this temporarily as it has too high an
528+
# overhead for initialsyncs. We need to figure out a way that the
529+
# bundling can be done *before* the events are stored in the
530+
# SyncResponseCache so that this part can be synchronous.
531+
#
532+
# Ensure to re-enable the test at tests/rest/client/test_relations.py::RelationsTestCase.test_bundled_aggregations.
533+
bundle_aggregations=False,
526534
token_id=token_id,
527535
event_format=event_formatter,
528536
only_event_fields=only_fields,

tests/rest/client/test_relations.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -574,11 +574,11 @@ def _find_and_assert_event(events):
574574
assert_bundle(channel.json_body["event"]["unsigned"].get("m.relations"))
575575

576576
# Request sync.
577-
channel = self.make_request("GET", "/sync", access_token=self.user_token)
578-
self.assertEquals(200, channel.code, channel.json_body)
579-
room_timeline = channel.json_body["rooms"]["join"][self.room]["timeline"]
580-
self.assertTrue(room_timeline["limited"])
581-
_find_and_assert_event(room_timeline["events"])
577+
# channel = self.make_request("GET", "/sync", access_token=self.user_token)
578+
# self.assertEquals(200, channel.code, channel.json_body)
579+
# room_timeline = channel.json_body["rooms"]["join"][self.room]["timeline"]
580+
# self.assertTrue(room_timeline["limited"])
581+
# _find_and_assert_event(room_timeline["events"])
582582

583583
# Note that /relations is tested separately in test_aggregation_get_event_for_thread
584584
# since it needs different data configured.

0 commit comments

Comments
 (0)