Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3590 from matrix-org/rav/persist_events_metrics
Browse files Browse the repository at this point in the history
Add some measure blocks to persist_events
  • Loading branch information
richvdh authored Jul 24, 2018
2 parents f559119 + 30957a9 commit 2601ee2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions changelog.d/3590.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add some measure blocks to persist_events
32 changes: 21 additions & 11 deletions synapse/storage/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,19 +417,29 @@ def _persist_events(self, events_and_contexts, backfilled=False,
logger.info(
"Calculating state delta for room %s", room_id,
)
current_state = yield self._get_new_state_after_events(
room_id,
ev_ctx_rm,
latest_event_ids,
new_latest_event_ids,
)

with Measure(
self._clock,
"persist_events.get_new_state_after_events",
):
current_state = yield self._get_new_state_after_events(
room_id,
ev_ctx_rm,
latest_event_ids,
new_latest_event_ids,
)

if current_state is not None:
current_state_for_room[room_id] = current_state
delta = yield self._calculate_state_delta(
room_id, current_state,
)
if delta is not None:
state_delta_for_room[room_id] = delta
with Measure(
self._clock,
"persist_events.calculate_state_delta",
):
delta = yield self._calculate_state_delta(
room_id, current_state,
)
if delta is not None:
state_delta_for_room[room_id] = delta

yield self.runInteraction(
"persist_events",
Expand Down

0 comments on commit 2601ee2

Please sign in to comment.