From 5946aa0877b043ad912d72fa6038adb8abbb7690 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 29 Jun 2017 15:38:48 +0100 Subject: [PATCH 1/2] Prefill forward extrems and event to state groups --- synapse/storage/events.py | 5 +++++ synapse/storage/state.py | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/synapse/storage/events.py b/synapse/storage/events.py index 2b7340c1d9..274426950a 100644 --- a/synapse/storage/events.py +++ b/synapse/storage/events.py @@ -403,6 +403,11 @@ class EventsStore(SQLBaseStore): (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,), 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 diff --git a/synapse/storage/state.py b/synapse/storage/state.py index d1e679719b..5673e4aa96 100644 --- a/synapse/storage/state.py +++ b/synapse/storage/state.py @@ -315,6 +315,12 @@ class StateStore(SQLBaseStore): ], ) + 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. @@ -584,8 +590,8 @@ class StateStore(SQLBaseStore): 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={ From 6ff14ddd2e93f569c3b4ace979f795f57da6c09c Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 29 Jun 2017 15:47:37 +0100 Subject: [PATCH 2/2] Make into list --- synapse/storage/events.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/storage/events.py b/synapse/storage/events.py index 274426950a..7002b3752e 100644 --- a/synapse/storage/events.py +++ b/synapse/storage/events.py @@ -405,7 +405,7 @@ class EventsStore(SQLBaseStore): for room_id, latest_event_ids in new_forward_extremeties.iteritems(): self.get_latest_event_ids_in_room.prefill( - (room_id,), latest_event_ids + (room_id,), list(latest_event_ids) ) @defer.inlineCallbacks