summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2018-10-09 09:48:56 +0100
committerGitHub <noreply@github.com>2018-10-09 09:48:56 +0100
commit2418e7811a318d2bbb695e9d7e7a1d762e86d9d5 (patch)
treef35d618bf6950888ffed9832dd0aa39e871da308 /synapse
parentMerge pull request #3995 from matrix-org/rav/no_deextrem_outliers (diff)
parentOptimisation for filter_events_for_server (diff)
downloadsynapse-2418e7811a318d2bbb695e9d7e7a1d762e86d9d5.tar.xz
Merge pull request #4017 from matrix-org/rav/optimise_filter_events_for_server
Optimisation for filter_events_for_server
Diffstat (limited to 'synapse')
-rw-r--r--synapse/visibility.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/synapse/visibility.py b/synapse/visibility.py
index d4680863d3..c64ad2144c 100644
--- a/synapse/visibility.py
+++ b/synapse/visibility.py
@@ -324,14 +324,13 @@ def filter_events_for_server(store, server_name, events):
     # server's domain.
     #
     # event_to_state_ids contains lots of duplicates, so it turns out to be
-    # cheaper to build a complete set of unique
-    # ((type, state_key), event_id) tuples, and then filter out the ones we
-    # don't want.
+    # cheaper to build a complete event_id => (type, state_key) dict, and then
+    # filter out the ones we don't want
     #
-    state_key_to_event_id_set = {
-        e
+    event_id_to_state_key = {
+        event_id: key
         for key_to_eid in itervalues(event_to_state_ids)
-        for e in key_to_eid.items()
+        for key, event_id in iteritems(key_to_eid)
     }
 
     def include(typ, state_key):
@@ -346,7 +345,7 @@ def filter_events_for_server(store, server_name, events):
 
     event_map = yield store.get_events([
         e_id
-        for key, e_id in state_key_to_event_id_set
+        for e_id, key in iteritems(event_id_to_state_key)
         if include(key[0], key[1])
     ])