Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(event cache): leaner updates when clearing/shrinking to the last chunk #4709

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Feb 24, 2025

I wanted to look at what it'd take to implement the TODOs about clearing, and I think I got them right, in the first commit; the only thing to pay attention to was the last_index_per_reader that needed an update when clearing updates.

But this wasn't sufficient to actually get rid of the spurious updates I've introduced in a previous test, because we're extending the previous updates with the ones caused by the shrink/reset. Instead, I've tried passing the updates diff vector as a &mut parameter to reset/shrink etc., but it makes the APIs a bit uglier, but eventually it behaves as I expected. What do you think @Hywan?

@bnjbvr bnjbvr requested a review from Hywan February 24, 2025 16:18
@bnjbvr bnjbvr requested a review from a team as a code owner February 24, 2025 16:18
Copy link
Member

@Hywan Hywan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm convinced by the first patch, thanks! I've a question about the second patch.

pub async fn reset(&mut self) -> Result<Vec<VectorDiff<TimelineEvent>>, EventCacheError> {
pub async fn reset(
&mut self,
sync_timeline_events_diffs: &mut Vec<VectorDiff<TimelineEvent>>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you pass a &mut instead of keeping to return the diffs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was to follow the pattern introduced in replace_with, which makes use of this function. I can isolate using the pattern to replace_with / shrink_to_last_chunk, if you'd prefer, and have the override happen there?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm struggling to see how it will look like but if the idea is to remove this &mut, I think I would prefer that yes!

Copy link

codecov bot commented Feb 24, 2025

Codecov Report

Attention: Patch coverage is 95.83333% with 1 line in your changes missing coverage. Please review.

Project coverage is 85.95%. Comparing base (f3f37a3) to head (c96af68).

Files with missing lines Patch % Lines
crates/matrix-sdk/src/event_cache/room/mod.rs 92.85% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4709   +/-   ##
=======================================
  Coverage   85.94%   85.95%           
=======================================
  Files         290      290           
  Lines       33892    33906   +14     
=======================================
+ Hits        29130    29145   +15     
+ Misses       4762     4761    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants