mirror of
https://github.com/element-hq/synapse.git
synced 2024-12-20 19:10:45 +03:00
TEMPORARY Subdivide _resolve_events Measure blocks
This commit is contained in:
parent
96769a229c
commit
f3db863420
1 changed files with 92 additions and 79 deletions
|
@ -38,6 +38,7 @@ from synapse.api.errors import AuthError
|
||||||
from synapse.api.room_versions import RoomVersion
|
from synapse.api.room_versions import RoomVersion
|
||||||
from synapse.events import EventBase
|
from synapse.events import EventBase
|
||||||
from synapse.types import MutableStateMap, StateMap, StrCollection
|
from synapse.types import MutableStateMap, StateMap, StrCollection
|
||||||
|
from synapse.util.metrics import Measure
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -104,7 +105,7 @@ async def resolve_events_with_store(
|
||||||
Returns:
|
Returns:
|
||||||
A map from (type, state_key) to event_id.
|
A map from (type, state_key) to event_id.
|
||||||
"""
|
"""
|
||||||
|
with Measure(clock, "rei_state_res:rews2_a"): # TODO temporary (rei)
|
||||||
logger.debug("Computing conflicted state")
|
logger.debug("Computing conflicted state")
|
||||||
|
|
||||||
# We use event_map as a cache, so if its None we need to initialize it
|
# We use event_map as a cache, so if its None we need to initialize it
|
||||||
|
@ -126,6 +127,7 @@ async def resolve_events_with_store(
|
||||||
room_id, state_sets, event_map, state_res_store
|
room_id, state_sets, event_map, state_res_store
|
||||||
)
|
)
|
||||||
|
|
||||||
|
with Measure(clock, "rei_state_res:rews2_b"): # TODO temporary (rei)
|
||||||
full_conflicted_set = set(
|
full_conflicted_set = set(
|
||||||
itertools.chain(
|
itertools.chain(
|
||||||
itertools.chain.from_iterable(conflicted_state.values()), auth_diff
|
itertools.chain.from_iterable(conflicted_state.values()), auth_diff
|
||||||
|
@ -138,6 +140,7 @@ async def resolve_events_with_store(
|
||||||
)
|
)
|
||||||
event_map.update(events)
|
event_map.update(events)
|
||||||
|
|
||||||
|
with Measure(clock, "rei_state_res:rews2_c"): # TODO temporary (rei)
|
||||||
# everything in the event map should be in the right room
|
# everything in the event map should be in the right room
|
||||||
for event in event_map.values():
|
for event in event_map.values():
|
||||||
if event.room_id != room_id:
|
if event.room_id != room_id:
|
||||||
|
@ -159,12 +162,19 @@ async def resolve_events_with_store(
|
||||||
eid for eid in full_conflicted_set if _is_power_event(event_map[eid])
|
eid for eid in full_conflicted_set if _is_power_event(event_map[eid])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
with Measure(clock, "rei_state_res:rews2_d"): # TODO temporary (rei)
|
||||||
sorted_power_events = await _reverse_topological_power_sort(
|
sorted_power_events = await _reverse_topological_power_sort(
|
||||||
clock, room_id, power_events, event_map, state_res_store, full_conflicted_set
|
clock,
|
||||||
|
room_id,
|
||||||
|
power_events,
|
||||||
|
event_map,
|
||||||
|
state_res_store,
|
||||||
|
full_conflicted_set,
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.debug("sorted %d power events", len(sorted_power_events))
|
logger.debug("sorted %d power events", len(sorted_power_events))
|
||||||
|
|
||||||
|
with Measure(clock, "rei_state_res:rews2_e"): # TODO temporary (rei)
|
||||||
# Now sequentially auth each one
|
# Now sequentially auth each one
|
||||||
resolved_state = await _iterative_auth_checks(
|
resolved_state = await _iterative_auth_checks(
|
||||||
clock,
|
clock,
|
||||||
|
@ -178,6 +188,7 @@ async def resolve_events_with_store(
|
||||||
|
|
||||||
logger.debug("resolved power events")
|
logger.debug("resolved power events")
|
||||||
|
|
||||||
|
with Measure(clock, "rei_state_res:rews2_f"): # TODO temporary (rei)
|
||||||
# OK, so we've now resolved the power events. Now sort the remaining
|
# OK, so we've now resolved the power events. Now sort the remaining
|
||||||
# events using the mainline of the resolved power level.
|
# events using the mainline of the resolved power level.
|
||||||
|
|
||||||
|
@ -188,11 +199,13 @@ async def resolve_events_with_store(
|
||||||
|
|
||||||
logger.debug("sorting %d remaining events", len(leftover_events))
|
logger.debug("sorting %d remaining events", len(leftover_events))
|
||||||
|
|
||||||
|
with Measure(clock, "rei_state_res:rews2_g"): # TODO temporary (rei)
|
||||||
pl = resolved_state.get((EventTypes.PowerLevels, ""), None)
|
pl = resolved_state.get((EventTypes.PowerLevels, ""), None)
|
||||||
leftover_events = await _mainline_sort(
|
leftover_events = await _mainline_sort(
|
||||||
clock, room_id, leftover_events, pl, event_map, state_res_store
|
clock, room_id, leftover_events, pl, event_map, state_res_store
|
||||||
)
|
)
|
||||||
|
|
||||||
|
with Measure(clock, "rei_state_res:rews2_h"): # TODO temporary (rei)
|
||||||
logger.debug("resolving remaining events")
|
logger.debug("resolving remaining events")
|
||||||
|
|
||||||
resolved_state = await _iterative_auth_checks(
|
resolved_state = await _iterative_auth_checks(
|
||||||
|
|
Loading…
Reference in a new issue