summary refs log tree commit diff
path: root/synapse/handlers/message.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-04-15 14:21:59 +0100
committerErik Johnston <erik@matrix.org>2015-04-15 14:21:59 +0100
commitbc6cef823f20f3d14c25ee5409fdea44e518087e (patch)
tree2fc6b2ba417bf9e85acec42c0209040700c0bcd1 /synapse/handlers/message.py
parentParellelize initial sync (diff)
downloadsynapse-bc6cef823f20f3d14c25ee5409fdea44e518087e.tar.xz
Do more parellelization for initialSync
Diffstat (limited to '')
-rw-r--r--synapse/handlers/message.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py
index 9c2ef94290..9667bb8674 100644
--- a/synapse/handlers/message.py
+++ b/synapse/handlers/message.py
@@ -293,10 +293,17 @@ class MessageHandler(BaseHandler):
             if event.membership != Membership.JOIN:
                 return
             try:
-                messages, token = yield self.store.get_recent_events_for_room(
-                    event.room_id,
-                    limit=limit,
-                    end_token=now_token.room_key,
+                (messages, token), current_state = yield defer.gatherResults(
+                    [
+                        self.store.get_recent_events_for_room(
+                            event.room_id,
+                            limit=limit,
+                            end_token=now_token.room_key,
+                        ),
+                        self.state_handler.get_current_state(
+                            event.room_id
+                        ),
+                    ]
                 )
 
                 start_token = now_token.copy_and_replace("room_key", token[0])
@@ -312,9 +319,6 @@ class MessageHandler(BaseHandler):
                     "end": end_token.to_string(),
                 }
 
-                current_state = yield self.state_handler.get_current_state(
-                    event.room_id
-                )
                 d["state"] = [
                     serialize_event(c, time_now, as_client_event)
                     for c in current_state.values()