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

Commit

Permalink
disable LL for incr syncs, and log incr sync stats (#3840)
Browse files Browse the repository at this point in the history
  • Loading branch information
ara4n authored Sep 11, 2018
1 parent 2527370 commit c4aa9d6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelog.d/3840.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disable lazy loading for incremental syncs for now
38 changes: 32 additions & 6 deletions synapse/handlers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,26 @@ def compute_state_delta(self, room_id, batch, sync_config, since_token, now_toke
lazy_load_members=lazy_load_members,
)
elif batch.limited:
state_at_timeline_start = yield self.store.get_state_ids_for_event(
batch.events[0].event_id, types=types,
filtered_types=filtered_types,
)

# for now, we disable LL for gappy syncs - see
# https://github.com/vector-im/riot-web/issues/7211#issuecomment-419976346
# N.B. this slows down incr syncs as we are now processing way
# more state in the server than if we were LLing.
#
# We still have to filter timeline_start to LL entries (above) in order
# for _calculate_state's LL logic to work, as we have to include LL
# members for timeline senders in case they weren't loaded in the initial
# sync. We do this by (counterintuitively) by filtering timeline_start
# members to just be ones which were timeline senders, which then ensures
# all of the rest get included in the state block (if we need to know
# about them).
types = None
filtered_types = None

state_at_previous_sync = yield self.get_state_at(
room_id, stream_position=since_token, types=types,
filtered_types=filtered_types,
Expand All @@ -746,23 +766,19 @@ def compute_state_delta(self, room_id, batch, sync_config, since_token, now_toke
filtered_types=filtered_types,
)

state_at_timeline_start = yield self.store.get_state_ids_for_event(
batch.events[0].event_id, types=types,
filtered_types=filtered_types,
)

state_ids = _calculate_state(
timeline_contains=timeline_state,
timeline_start=state_at_timeline_start,
previous=state_at_previous_sync,
current=current_state_ids,
# we have to include LL members in case LL initial sync missed them
lazy_load_members=lazy_load_members,
)
else:
state_ids = {}
if lazy_load_members:
if types:
# We're returning an incremental (or initial) sync, with no
# We're returning an incremental sync, with no
# "gap" since the previous sync, so normally there would be
# no state to return.
# But we're lazy-loading, so the client might need some more
Expand Down Expand Up @@ -1681,6 +1697,16 @@ def _generate_room_entry(self, sync_result_builder, ignored_users,
unread_notifications["highlight_count"] = notifs["highlight_count"]

sync_result_builder.joined.append(room_sync)

if batch.limited:
user_id = sync_result_builder.sync_config.user.to_string()
logger.info(
"Incremental syncing room %s for user %s with %d state events" % (
room_id,
user_id,
len(state),
)
)
elif room_builder.rtype == "archived":
room_sync = ArchivedSyncResult(
room_id=room_id,
Expand Down

0 comments on commit c4aa9d6

Please sign in to comment.