summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--changelog.d/7725.misc1
-rw-r--r--synapse/state/v2.py3
2 files changed, 3 insertions, 1 deletions
diff --git a/changelog.d/7725.misc b/changelog.d/7725.misc
new file mode 100644
index 0000000000..f295a45521
--- /dev/null
+++ b/changelog.d/7725.misc
@@ -0,0 +1 @@
+Speed up state res v2 across large state differences.
diff --git a/synapse/state/v2.py b/synapse/state/v2.py
index e25bc5d264..57eadce4e6 100644
--- a/synapse/state/v2.py
+++ b/synapse/state/v2.py
@@ -133,8 +133,9 @@ def resolve_events_with_store(
     # OK, so we've now resolved the power events. Now sort the remaining
     # events using the mainline of the resolved power level.
 
+    set_power_events = set(sorted_power_events)
     leftover_events = [
-        ev_id for ev_id in full_conflicted_set if ev_id not in sorted_power_events
+        ev_id for ev_id in full_conflicted_set if ev_id not in set_power_events
     ]
 
     logger.debug("sorting %d remaining events", len(leftover_events))