mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-26 03:25:53 +03:00
Merge branch 'develop' into matthew/filter_members
This commit is contained in:
commit
454f59b7ad
2 changed files with 5 additions and 12 deletions
1
changelog.d/3592.misc
Normal file
1
changelog.d/3592.misc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Speed up calculating state deltas in persist_event loop
|
|
@ -439,8 +439,7 @@ class EventsStore(EventsWorkerStore):
|
||||||
delta = yield self._calculate_state_delta(
|
delta = yield self._calculate_state_delta(
|
||||||
room_id, current_state,
|
room_id, current_state,
|
||||||
)
|
)
|
||||||
if delta is not None:
|
state_delta_for_room[room_id] = delta
|
||||||
state_delta_for_room[room_id] = delta
|
|
||||||
|
|
||||||
yield self.runInteraction(
|
yield self.runInteraction(
|
||||||
"persist_events",
|
"persist_events",
|
||||||
|
@ -655,21 +654,14 @@ class EventsStore(EventsWorkerStore):
|
||||||
"""
|
"""
|
||||||
existing_state = yield self.get_current_state_ids(room_id)
|
existing_state = yield self.get_current_state_ids(room_id)
|
||||||
|
|
||||||
existing_events = set(itervalues(existing_state))
|
|
||||||
new_events = set(ev_id for ev_id in itervalues(current_state))
|
|
||||||
changed_events = existing_events ^ new_events
|
|
||||||
|
|
||||||
if not changed_events:
|
|
||||||
return
|
|
||||||
|
|
||||||
to_delete = {
|
to_delete = {
|
||||||
key: ev_id for key, ev_id in iteritems(existing_state)
|
key: ev_id for key, ev_id in iteritems(existing_state)
|
||||||
if ev_id in changed_events
|
if ev_id != current_state.get(key)
|
||||||
}
|
}
|
||||||
events_to_insert = (new_events - existing_events)
|
|
||||||
to_insert = {
|
to_insert = {
|
||||||
key: ev_id for key, ev_id in iteritems(current_state)
|
key: ev_id for key, ev_id in iteritems(current_state)
|
||||||
if ev_id in events_to_insert
|
if ev_id != existing_state.get(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer.returnValue((to_delete, to_insert))
|
defer.returnValue((to_delete, to_insert))
|
||||||
|
|
Loading…
Reference in a new issue