Add logging to initialSync

This commit is contained in:
Erik Johnston 2015-05-01 11:24:03 +01:00
parent 657298cebd
commit 171829bb94
1 changed files with 20 additions and 0 deletions

View File

@ -250,31 +250,47 @@ class MessageHandler(BaseHandler):
is joined on, may return a "messages" key with messages, depending is joined on, may return a "messages" key with messages, depending
on the specified PaginationConfig. on the specified PaginationConfig.
""" """
start_time = self.clock.time_msec()
def delta():
return self.clock.time_msec() - start_time
logger.info("initial_sync: start")
room_list = yield self.store.get_rooms_for_user_where_membership_is( room_list = yield self.store.get_rooms_for_user_where_membership_is(
user_id=user_id, user_id=user_id,
membership_list=[Membership.INVITE, Membership.JOIN] membership_list=[Membership.INVITE, Membership.JOIN]
) )
logger.info("initial_sync: got_rooms %d", delta())
user = UserID.from_string(user_id) user = UserID.from_string(user_id)
rooms_ret = [] rooms_ret = []
now_token = yield self.hs.get_event_sources().get_current_token() now_token = yield self.hs.get_event_sources().get_current_token()
logger.info("initial_sync: now_token %d", delta())
presence_stream = self.hs.get_event_sources().sources["presence"] presence_stream = self.hs.get_event_sources().sources["presence"]
pagination_config = PaginationConfig(from_token=now_token) pagination_config = PaginationConfig(from_token=now_token)
presence, _ = yield presence_stream.get_pagination_rows( presence, _ = yield presence_stream.get_pagination_rows(
user, pagination_config.get_source_config("presence"), None user, pagination_config.get_source_config("presence"), None
) )
logger.info("initial_sync: presence_done %d", delta())
public_room_ids = yield self.store.get_public_room_ids() public_room_ids = yield self.store.get_public_room_ids()
logger.info("initial_sync: public_rooms %d", delta())
limit = pagin_config.limit limit = pagin_config.limit
if limit is None: if limit is None:
limit = 10 limit = 10
@defer.inlineCallbacks @defer.inlineCallbacks
def handle_room(event): def handle_room(event):
logger.info("initial_sync: start: %s %d", event.room_id, delta())
d = { d = {
"room_id": event.room_id, "room_id": event.room_id,
"membership": event.membership, "membership": event.membership,
@ -325,11 +341,15 @@ class MessageHandler(BaseHandler):
except: except:
logger.exception("Failed to get snapshot") logger.exception("Failed to get snapshot")
logger.info("initial_sync: end: %s %d", event.room_id, delta())
yield defer.gatherResults( yield defer.gatherResults(
[handle_room(e) for e in room_list], [handle_room(e) for e in room_list],
consumeErrors=True consumeErrors=True
) )
logger.info("initial_sync: done", delta())
ret = { ret = {
"rooms": rooms_ret, "rooms": rooms_ret,
"presence": presence, "presence": presence,