summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2017-02-27 19:15:59 +0000
committerGitHub <noreply@github.com>2017-02-27 19:15:59 +0000
commiteda96586ca8a632da16d4d24034f221793f87890 (patch)
tree740bce76079d2ad00b0ade11390d6ecd4c0e7315 /synapse
parentPop rather than del from dict (diff)
parentRemove needless check (diff)
downloadsynapse-eda96586ca8a632da16d4d24034f221793f87890.tar.xz
Merge pull request #1955 from matrix-org/erikj/current_state_query_bypass
Don't fetch current state in common case
Diffstat (limited to 'synapse')
-rw-r--r--synapse/storage/events.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/synapse/storage/events.py b/synapse/storage/events.py
index c88f689d3a..db01eb6d14 100644
--- a/synapse/storage/events.py
+++ b/synapse/storage/events.py
@@ -311,6 +311,21 @@ class EventsStore(SQLBaseStore):
 
                             new_forward_extremeties[room_id] = new_latest_event_ids
 
+                            len_1 = (
+                                len(latest_event_ids) == 1
+                                and len(new_latest_event_ids) == 1
+                            )
+                            if len_1:
+                                all_single_prev_not_state = all(
+                                    len(event.prev_events) == 1
+                                    and not event.is_state()
+                                    for event, ctx in ev_ctx_rm
+                                )
+                                # Don't bother calculating state if they're just
+                                # a long chain of single ancestor non-state events.
+                                if all_single_prev_not_state:
+                                    continue
+
                             state = yield self._calculate_state_delta(
                                 room_id, ev_ctx_rm, new_latest_event_ids
                             )