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

Faster joins: do not wait for full state when creating events to send #14403

Merged
merged 3 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/14403.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Faster joins: do not wait for full state when creating events to send.
1 change: 1 addition & 0 deletions synapse/events/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ async def build(
state_filter=StateFilter.from_types(
auth_types_for_event(self.room_version, self)
),
await_full_state=False,
MatMaul marked this conversation as resolved.
Show resolved Hide resolved
)
auth_event_ids = self._event_auth_handler.compute_auth_events(
self, state_ids
Expand Down
8 changes: 7 additions & 1 deletion synapse/state/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ async def compute_state_after_events(
room_id: str,
event_ids: Collection[str],
state_filter: Optional[StateFilter] = None,
await_full_state: bool = True,
MatMaul marked this conversation as resolved.
Show resolved Hide resolved
) -> StateMap[str]:
"""Fetch the state after each of the given event IDs. Resolve them and return.

Expand All @@ -200,13 +201,18 @@ async def compute_state_after_events(
Args:
room_id: the room_id containing the given events.
event_ids: the events whose state should be fetched and resolved.
await_full_state: if `True`, will block if we do not yet have complete state
at the given `event_id`s, regardless of whether `state_filter` is
satisfied by partial state.

Returns:
the state dict (a mapping from (event_type, state_key) -> event_id) which
holds the resolution of the states after the given event IDs.
"""
logger.debug("calling resolve_state_groups from compute_state_after_events")
ret = await self.resolve_state_groups_for_events(room_id, event_ids)
ret = await self.resolve_state_groups_for_events(
room_id, event_ids, await_full_state
MatMaul marked this conversation as resolved.
Show resolved Hide resolved
)
return await ret.get_state(self._state_storage_controller, state_filter)

async def get_current_user_ids_in_room(
Expand Down