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

Prefill forward extrems and event to state groups #2321

Merged
merged 2 commits into from
Jun 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions synapse/storage/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,11 @@ def _persist_events(self, events_and_contexts, backfilled=False,
(room_id, ), new_state
)

for room_id, latest_event_ids in new_forward_extremeties.iteritems():
self.get_latest_event_ids_in_room.prefill(
(room_id,), list(latest_event_ids)
)

@defer.inlineCallbacks
def _calculate_new_extremeties(self, room_id, event_contexts, latest_event_ids):
"""Calculates the new forward extremeties for a room given events to
Expand Down
10 changes: 8 additions & 2 deletions synapse/storage/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,12 @@ def _store_mult_state_groups_txn(self, txn, events_and_contexts):
],
)

for event_id, state_group_id in state_groups.iteritems():
txn.call_after(
self._get_state_group_for_event.prefill,
(event_id,), state_group_id
)

def _count_state_group_hops_txn(self, txn, state_group):
"""Given a state group, count how many hops there are in the tree.

Expand Down Expand Up @@ -584,8 +590,8 @@ def get_state_ids_for_event(self, event_id, types=None):
state_map = yield self.get_state_ids_for_events([event_id], types)
defer.returnValue(state_map[event_id])

@cached(num_args=2, max_entries=50000)
def _get_state_group_for_event(self, room_id, event_id):
@cached(max_entries=50000)
def _get_state_group_for_event(self, event_id):
return self._simple_select_one_onecol(
table="event_to_state_groups",
keyvalues={
Expand Down