This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Fetch less state when we _compute_event_context_with_maybe_missing_prevs#15616
Closed
MadLittleMods wants to merge 3 commits into
Closed
Fetch less state when we _compute_event_context_with_maybe_missing_prevs#15616MadLittleMods wants to merge 3 commits into
_compute_event_context_with_maybe_missing_prevs#15616MadLittleMods wants to merge 3 commits into
Conversation
Member
|
This seems to have been a placeholder. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fetch less state when we
_compute_event_context_with_maybe_missing_prevsPart of making
/messagesfaster: #13356Background
When we have to
_compute_event_context_with_maybe_missing_prevs,_get_state_groups_from_groupscurrently takes up most of the time. It makes the following recursive query for each state group given which goes up the entire state_group chain and returns the complete distinct state which means thousands of membership events at the very least. For example, with a random/messagesrequest in the Matrix HQ room we did 10x of these queries which each took 0.5-2 seconds and return roughly 88k events every time totaling 14s.https://explain.depesz.com/s/OuOe
https://explain.dalibo.com/plan/ef6bc290f2dced17
EXPLAIN ANAYLZEquery outputFull Jaeger trace JSON
Questions/ideas
Do we really need all of this state?
Can we get away with adding a
state_filterthat only fetches the auth event types out?StateFilter.from_types(event_auth.auth_types_for_event(event.room_version, event))Or maybe we can avoid fetching all
m.room.memberevents except for the one that pertains to the eventsender?Another idea, since we fetch state for many
state_groups, can we re-use the work from one to the other? Perhaps we can have one recursive query starting at the maxstate_groupgiven and somehow assembles what we want for each of the subsequent state groups.For reference, we previously optimized the SQL query in
filter_events_for_client->_get_state_groups_from_groupsin #14527 but that was a case where we already had astate_filterto only grab them.room.history_visibilityandm.room.memberevents.Dev notes
Grabbing all of the state via
_get_state_groups_from_groupsis the slowest part of_compute_event_context_with_maybe_missing_prevs_compute_event_context_with_maybe_missing_prevs_get_state_groups_from_groups🐢Of all the state we grab in
_compute_event_context_with_maybe_missing_prevs, we only ever use TODO_process_pulled_event_compute_event_context_with_maybe_missing_prevs_process_received_pdu_check_event_auth_state_resolution_handler.resolve_events_with_store(...)event_auth.auth_types_for_event(event.room_version, event)) 🎈_check_for_soft_fail-> Looks for auth events again 🎈
_run_push_actions_and_persist_event-> Looks for
m.room.power_levels🎈filter_event_for_clients_with_state->
EventTypes.RoomHistoryVisibility🎈Pull Request Checklist
EventStoretoEventWorkerStore.".code blocks.(run the linters)