feat(sdk): Flatten the hierarchy of caches in the Event Cache, part 3: Event-focused#6603
Merged
Conversation
21 tasks
c749995 to
24aee00
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## features/event-cache-refactoring #6603 +/- ##
====================================================================
- Coverage 89.89% 89.84% -0.05%
====================================================================
Files 385 385
Lines 109052 109074 +22
Branches 109052 109074 +22
====================================================================
- Hits 98035 98002 -33
- Misses 7310 7348 +38
- Partials 3707 3724 +17 ☔ View full report in Codecov by Sentry. |
24aee00 to
8ea9363
Compare
b62812a to
28e82f4
Compare
…sed`. This patch moves `EventFocusedCacheKey` from the `room` module into the `event_focused` module because it's about the event-focused cache.
…already exists. This patch clones an existing `WeakRoom` instead of creating another one from scratch.
This patch removes the `room` argument of `EventFocusedCache(Inner)::start_from`. First off, this is not required as the struct already has the `WeakRoom`. Second, this is dangerous as the two rooms might differ, or different rooms might be used between called. This can be really inconsistent. This patch removes the `room` argument and the code uses the `WeakRoom` in the struct instead.
This patch stores all the `EventFocusedCache` in `Caches`.
…dCacheKey`. This patch renames the `EventFocusedCacheKey::focused` field to `focused_event_id` to clarify what is focused.
…caches. This patch updates R2D2 to uses `Caches` via `EventCache::inner::all_caches_for_room` to get a reference to all the caches. It updates the way the event-focused cache was updated. No more ABBA lock problem here. The code is simplified.
This patch reorganises the imports. Notably, `RoomPagination` is a submodule: no need to import it from `crate::event_cache`.
…tate`. This patch renames `EventFocusedCacheInner` to `EventFocusedCacheState` because it contains the state of the `EventFocusedCacheState`.
This patch updates `ResetCaches` to handle the event-focused caches.
8ea9363 to
420c093
Compare
jmartinesp
approved these changes
May 22, 2026
|
|
||
| OwnedRwLockWriteGuard::downgrade_map( | ||
| event_focused_caches, | ||
| |event_focused_caches| event_focused_caches.get(&key).unwrap(), |
Contributor
There was a problem hiding this comment.
I guess it's safe to unwrap here because we just added it above?
93a9d40
into
matrix-org:features/event-cache-refactoring
110 of 116 checks passed
21 tasks
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR is the sequel of #6517. This time, we are “flattening” the pinned-events cache, i.e. it extracts the pinned-event cache from the room cache to move it directly in
Caches. The tree goes from:graph TD; EventCache-->Caches; Caches-->RoomEventCache; RoomEventCache-->RoomEventCacheState; RoomEventCacheState-->EventFocusedCache; EventFocusedCache-->EventFocusedCacheInner;to:
graph TD; EventCache-->Caches; Caches-->RoomEventCache; Caches-->EventFocusedCache; RoomEventCache-->RoomEventCacheState; EventFocusedCache-->EventFocusedCacheState;This change is simpler than the previous ones (for thread caches or pinned-event cache) because an event-focused cache doesn't listen to live sync update. Consequently, we don't need any form of aggregator (in the “pipelines”) and so on.
New Features or Breaking Changes
First and foremost,
EventFocusedCacheInneris renamedEventFocusedCacheStatebecause it contains its state.Then, all methods related to event-focused caches on
RoomEventCacheare removed, for example:RoomEventCache::get_or_create_event_focused_cache, orRoomEventCache::get_event_focused_cacheare now removed.EventCachenow provides 1 new public method:event_focusedto lazily access anEventFocusedCache.One new feature is that it's now possible to reset an event-focused cache, whilst it was not possible before.
Bug Fixes
Redecryptor(aka R2D2) has no more ABBA locking problem when replacing resolved UTDs in various caches.Redecryptor“extends”EventCacheand uses theCachestype. Since all caches are now separated from each other, the initial locking problem no longer exists.(see Writing changelog entries).
Signed-off-by: