This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Conversation
If we send out an event which refers to `prev_events` which other servers in the federation are missing, then (after a round or two of backfill attempts), they will end up asking us for `/state_ids` at a particular point in the DAG. As per #7893, this is quite expensive, and we tend to see lots of very similar requests around the same time. We can therefore handle this much more efficiently by using a cache, which (a) ensures that if we see the same request from multiple servers (or even the same server, multiple times), then they share the result, and (b) any other servers that miss the initial excitement can also benefit from the work. [It's interesting to note that `/state` has a cache for exactly this reason. `/state` is now essentially unused and replaced with `/state_ids`, but evidently when we replaced it we forgot to add a cache to the new endpoint.]
clokep
approved these changes
Jul 22, 2020
Comment on lines
+382
to
+384
| resp = await self._state_ids_resp_cache.wrap( | ||
| (room_id, event_id), self._on_state_ids_request_compute, room_id, event_id, | ||
| ) |
Member
There was a problem hiding this comment.
The call above to self._state_resp_cache gets wrapped by dict(), which we don't do here. It doesn't seem necessary, but curious about the difference.
Member
Author
There was a problem hiding this comment.
the dict there was added in https://github.com/matrix-org/synapse/pull/6176/files. It looks like it's so that we can add a room_version property after it comes out of the cache, without accidentally modifying the cached response.
It is unclear to me why that implementation was chosen instead of adding the room_id in _on_context_state_request_compute.
In any case, I think it's unnecessary in the new code.
babolivier
pushed a commit
that referenced
this pull request
Sep 1, 2021
* commit 'f88c48f3b': 1.18.0rc1 Fix error reporting when using `opentracing.trace` (#7961) Fix typing replication not being handled on master (#7959) Remove hacky error handling for inlineDeferreds. (#7950) Convert tests/rest/admin/test_room.py to unix file endings (#7953) Support oEmbed for media previews. (#7920) Convert state resolution to async/await (#7942) Fix up types and comments that refer to Deferreds. (#7945) Do not convert async functions to Deferreds in the interactive_auth_handler (#7944) Convert more of the media code to async/await (#7873) Return an empty body for OPTIONS requests. (#7886) Downgrade warning on client disconnect to INFO (#7928) Convert presence handler helpers to async/await. (#7939) Update the auth providers to be async. (#7935) Put a cache on `/state_ids` (#7931)
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.
If we send out an event which refers to
prev_eventswhich other servers inthe federation are missing, then (after a round or two of backfill attempts),
they will end up asking us for
/state_idsat a particular point in the DAG.As per #7893, this is quite
expensive, and we tend to see lots of very similar requests around the same
time.
We can therefore handle this much more efficiently by using a cache, which (a)
ensures that if we see the same request from multiple servers (or even the same
server, multiple times), then they share the result, and (b) any other servers
that miss the initial excitement can also benefit from the work.
[It's interesting to note that
/statehas a cache for exactly thisreason.
/stateis now essentially unused and replaced with/state_ids, butevidently when we replaced it we forgot to add a cache to the new endpoint.]