TEMPORARY Add more Measure blocks

matrix-org-hotfixes
Olivier Wilkinson (reivilibre) 2023-10-16 18:15:48 +01:00
parent f3db863420
commit adfa0fded3
1 changed files with 63 additions and 57 deletions

View File

@ -124,7 +124,7 @@ async def resolve_events_with_store(
# Also fetch all auth events that appear in only some of the state sets' # Also fetch all auth events that appear in only some of the state sets'
# auth chains. # auth chains.
auth_diff = await _get_auth_chain_difference( auth_diff = await _get_auth_chain_difference(
room_id, state_sets, event_map, state_res_store room_id, state_sets, event_map, state_res_store, clock
) )
with Measure(clock, "rei_state_res:rews2_b"): # TODO temporary (rei) with Measure(clock, "rei_state_res:rews2_b"): # TODO temporary (rei)
@ -284,6 +284,7 @@ async def _get_auth_chain_difference(
state_sets: Sequence[StateMap[str]], state_sets: Sequence[StateMap[str]],
unpersisted_events: Dict[str, EventBase], unpersisted_events: Dict[str, EventBase],
state_res_store: StateResolutionStore, state_res_store: StateResolutionStore,
clock: Clock,
) -> Set[str]: ) -> Set[str]:
"""Compare the auth chains of each state set and return the set of events """Compare the auth chains of each state set and return the set of events
that only appear in some, but not all of the auth chains. that only appear in some, but not all of the auth chains.
@ -315,6 +316,7 @@ async def _get_auth_chain_difference(
# event IDs if they appear in the `unpersisted_events`. This is the intersection of # event IDs if they appear in the `unpersisted_events`. This is the intersection of
# the event's auth chain with the events in `unpersisted_events` *plus* their # the event's auth chain with the events in `unpersisted_events` *plus* their
# auth event IDs. # auth event IDs.
with Measure(clock, "rei_state_res:rews2_a1"): # TODO temporary (rei)
events_to_auth_chain: Dict[str, Set[str]] = {} events_to_auth_chain: Dict[str, Set[str]] = {}
for event in unpersisted_events.values(): for event in unpersisted_events.values():
chain = {event.event_id} chain = {event.event_id}
@ -333,6 +335,7 @@ async def _get_auth_chain_difference(
# #
# Note: If there are no `unpersisted_events` (which is the common case), we can do a # Note: If there are no `unpersisted_events` (which is the common case), we can do a
# much simpler calculation. # much simpler calculation.
with Measure(clock, "rei_state_res:rews2_a2"): # TODO temporary (rei)
if unpersisted_events: if unpersisted_events:
# The list of state sets to pass to the store, where each state set is a set # The list of state sets to pass to the store, where each state set is a set
# of the event ids making up the state. This is similar to `state_sets`, # of the event ids making up the state. This is similar to `state_sets`,
@ -382,9 +385,12 @@ async def _get_auth_chain_difference(
auth_difference_unpersisted_part = () auth_difference_unpersisted_part = ()
state_sets_ids = [set(state_set.values()) for state_set in state_sets] state_sets_ids = [set(state_set.values()) for state_set in state_sets]
with Measure(clock, "rei_state_res:rews2_a3"): # TODO temporary (rei)
difference = await state_res_store.get_auth_chain_difference( difference = await state_res_store.get_auth_chain_difference(
room_id, state_sets_ids room_id, state_sets_ids
) )
with Measure(clock, "rei_state_res:rews2_a4"): # TODO temporary (rei)
difference.update(auth_difference_unpersisted_part) difference.update(auth_difference_unpersisted_part)
return difference return difference