matrix-org / matrix-org/matrix-rust-sdk

event cache: unload the pinned event cache at the appropriate time

Open
#6,179 0 comments 0 reactions 0 assignees View on GitHub
A-Event cache
Dominant language
Rust
Stars
2.3k
Forks
500
Avg merge
1d 16h
Merged PRs (30d)
106

Description

The new `PinnedEventCache` introduced recently is spawned lazily. It will spawn a task in the background as well, that will be correctly aborted when the parent container struct is dropped. However, there's nothing signaling, at the moment, that all pinned `Timeline`s are dead, and that the `PinnedEventCache` could be unloaded (i.e. the task could be aborted), resulting in unnecessary background processing, after an app has switched the view away from the pinned events timeline.

- We could likely reuse and generalize the mechanism introduced for the unthreaded room timeline (née `RoomEventCacheSubscriber`, which name would have to be generalized).
- Alternatively, we _could_ also just count pinned timelines as observers of the main room timeline — which make sense, since a pinned event timeline requires the unthreaded timeline to be alive and updated over time. Then, when the `RoomEventCacheSubscriber` drops, we could also unload the `PinnedEventCache`.
- (other million dollars idea goes here)

Contributor guide

Open the contributing guide

Research direction

Start by tracing PinnedEventCache, pinned Timeline lifetimes, and the existing RoomEventCacheSubscriber mechanism. Compare the proposed observer-counting and generalized-subscriber approaches; the work is done when the pinned cache task is unloaded after all pinned timelines are gone, without stopping while one remains.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.