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

State delta between two events for more efficient delivery and processing #13618

Open
MadLittleMods opened this issue Aug 24, 2022 · 0 comments
Labels
A-Federation A-Messages-Endpoint /messages client API endpoint (`RoomMessageListRestServlet`) (which also triggers /backfill) A-Performance Performance, both client-facing and admin-facing O-Occasional Affects or can be seen by some users regularly or most users rarely S-Minor Blocks non-critical functionality, workarounds exist. T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements.

Comments

@MadLittleMods
Copy link
Contributor

MadLittleMods commented Aug 24, 2022

Spawning from #13356 to make /messages faster which includes backfill


It's very inefficient to have to request the full room state (or state_ids) at a given event when we already have the majority of the state locally. For a room like #matrix:matrix.org, /state_ids gives 200k events (77k state_events, 122k auth_events) which by its sheer volume takes the sending server a while assemble a response, send it, and then we have process all of it 😱

It would be nice if we had an endpoint to get only the state that is different from event A to event B (the delta). This way the sending server doesn't have to send as much and we don't have process as many events to find the couple events that we need.

This new endpoint needs some spec thought and a proper MSC but creating an issue here so we can track the idea before that gets created. One potential option is adding some from/to query parameters to the existing /state_ids and /state endpoints.

  • GET /_matrix/federation/v1/state_ids/{roomId}?from_event_id=$a&to_event_id=$b
  • GET /_matrix/federation/v1/state/{roomId}?from_event_id=$a&to_event_id=$b

It might be good if we could also specify multiple pairs of events to help batch up multiple missing events.

Maybe similar to the existing /get_missing_events endpoint where you can specify earliest_events and latest_events


Related issues:

Dev notes

In Synapse, we can use our state_groups to to simplify the diff calculation.

compute_state_delta is used for /sync but is probably of interest as well.


(#13586)

# It would be better if we could query the difference from our known
# state to the given `event_id` so the sending server doesn't have to
# send as much and we don't have to process as many events. For example
# in a room like #matrixhq, we get 200k events (77k state_events, 122k
# auth_events) from this call.
(
state_event_ids,
auth_event_ids,
) = await self._federation_client.get_room_state_ids(
destination, room_id, event_id=event_id
)

@MadLittleMods MadLittleMods added the A-Messages-Endpoint /messages client API endpoint (`RoomMessageListRestServlet`) (which also triggers /backfill) label Aug 24, 2022
@DMRobertson DMRobertson added S-Minor Blocks non-critical functionality, workarounds exist. O-Occasional Affects or can be seen by some users regularly or most users rarely A-Performance T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements. A-Performance Performance, both client-facing and admin-facing and removed A-Performance labels Aug 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Federation A-Messages-Endpoint /messages client API endpoint (`RoomMessageListRestServlet`) (which also triggers /backfill) A-Performance Performance, both client-facing and admin-facing O-Occasional Affects or can be seen by some users regularly or most users rarely S-Minor Blocks non-critical functionality, workarounds exist. T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements.
Projects
None yet
Development

No branches or pull requests

2 participants