summary refs log tree commit diff
diff options
context:
space:
mode:
authorAmber Brown <hawkowl@atleastfornow.net>2018-09-07 00:24:43 +1000
committerGitHub <noreply@github.com>2018-09-07 00:24:43 +1000
commitee7c8bd2b5d65c11770d50bb284b3693c2622b89 (patch)
tree1a10e7561342c2f8bc7d3f6cf5c4b03cec23921f
parentMerge pull request #3804 from matrix-org/rav/fix_openssl_dep (diff)
parentNewsfile (diff)
downloadsynapse-ee7c8bd2b5d65c11770d50bb284b3693c2622b89.tar.xz
Merge pull request #3795 from matrix-org/erikj/faster_sync_state
User iter* during sync state calculations
-rw-r--r--changelog.d/3795.misc1
-rw-r--r--synapse/handlers/sync.py16
2 files changed, 9 insertions, 8 deletions
diff --git a/changelog.d/3795.misc b/changelog.d/3795.misc
new file mode 100644
index 0000000000..9f64ee5e2b
--- /dev/null
+++ b/changelog.d/3795.misc
@@ -0,0 +1 @@
+Make /sync slightly faster by avoiding needless copies
diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py
index 0091ceb80e..9f133ded3f 100644
--- a/synapse/handlers/sync.py
+++ b/synapse/handlers/sync.py
@@ -1729,17 +1729,17 @@ def _calculate_state(
     event_id_to_key = {
         e: key
         for key, e in itertools.chain(
-            timeline_contains.items(),
-            previous.items(),
-            timeline_start.items(),
-            current.items(),
+            iteritems(timeline_contains),
+            iteritems(previous),
+            iteritems(timeline_start),
+            iteritems(current),
         )
     }
 
-    c_ids = set(e for e in current.values())
-    ts_ids = set(e for e in timeline_start.values())
-    p_ids = set(e for e in previous.values())
-    tc_ids = set(e for e in timeline_contains.values())
+    c_ids = set(e for e in itervalues(current))
+    ts_ids = set(e for e in itervalues(timeline_start))
+    p_ids = set(e for e in itervalues(previous))
+    tc_ids = set(e for e in itervalues(timeline_contains))
 
     # If we are lazyloading room members, we explicitly add the membership events
     # for the senders in the timeline into the state block returned by /sync,