Skip to content

Conversation

@poljar
Copy link
Contributor

@poljar poljar commented Oct 3, 2025

This is very much a WIP PR. Eventually it will get split into different smaller PRs.

Things that still need to be addressed:

  • Don't load all events for a certain room when attempting to redecrypt events.
  • Decide what to do when the room key stream has lagged.
  • Handle the room key withheld stream as well.
  • Connect the UTD hook to the new redecryptor.
  • Port the timeline redecryption tests.
  • Completely remove the timeline redecryption logic. (this has been pushed to a separate PR).

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 3, 2025

CodSpeed Performance Report

Merging #5746 will not alter performance

Comparing poljar/event-cache/redecryptor (9508675) with main (f702364)

Summary

✅ 50 untouched

@poljar poljar force-pushed the poljar/event-cache/redecryptor branch from 54f3b5f to 0f4bbe5 Compare November 7, 2025 14:06
@poljar poljar marked this pull request as ready for review November 7, 2025 14:10
@poljar poljar requested a review from a team as a code owner November 7, 2025 14:10
@poljar poljar requested review from stefanceriu and removed request for a team November 7, 2025 14:10
@poljar poljar closed this Nov 7, 2025
@poljar poljar reopened this Nov 7, 2025
@poljar poljar force-pushed the poljar/event-cache/redecryptor branch from 0f4bbe5 to 9f1aff6 Compare November 7, 2025 14:14
@codecov
Copy link

codecov bot commented Nov 7, 2025

Codecov Report

❌ Patch coverage is 84.30493% with 70 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.59%. Comparing base (c064ca8) to head (9508675).
⚠️ Report is 59 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/matrix-sdk/src/event_cache/redecryptor.rs 83.60% 57 Missing and 13 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5746      +/-   ##
==========================================
- Coverage   88.61%   88.59%   -0.03%     
==========================================
  Files         361      362       +1     
  Lines      102160   102604     +444     
  Branches   102160   102604     +444     
==========================================
+ Hits        90532    90903     +371     
- Misses       7410     7469      +59     
- Partials     4218     4232      +14     

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

@poljar poljar force-pushed the poljar/event-cache/redecryptor branch from 9f1aff6 to c21daed Compare November 7, 2025 14:35
@poljar poljar force-pushed the poljar/event-cache/redecryptor branch from c21daed to d7d4730 Compare November 7, 2025 14:38
@stefanceriu stefanceriu requested review from Hywan and removed request for stefanceriu November 10, 2025 09:51
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.

Wow. That was an impressive set of patches.

How a simple problem gently piles more and more complexity. The resulting code is not complex however, and that's really great. Thank you for the great documentation, including inline documentation!

I've left a couple of feedback, but nothing requiring a huge change.

let (room_cache, _drop_handles) = self.for_room(room_id).await?;
let mut state = room_cache.inner.state.write().await;

let event_ids: Vec<_> = events.iter().map(|(event_id, _)| event_id).collect();
Copy link
Member

Choose a reason for hiding this comment

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

Can we compute event_ids if and only if trace! is enabled? Maybe with tracing::enabled!?

Alternatively, I confess it's a bit more logs but, I would put the trace! inside the loop, closer to replace_event_at, because it's where we are really replacing the event. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can we compute event_ids if and only if trace! is enabled? Maybe with tracing::enabled!?

Sadly we can't, as the event IDs are sent out as part of the RedecryptorReport, that's also the reason why we're cloning it in later parts of this patchset:

a2f89e8#diff-5c3b83b7260e87e30c1b6b3bfad8b5be005c31d142b825e75ff0e047680c2923R201

Alternatively, I confess it's a bit more logs but, I would put the trace! inside the loop, closer to replace_event_at, because it's where we are really replacing the event. Thoughts?

Hmm, I'm really worried about log spam here. If you're suggesting this because you want to avoid the building of the BTreeSet then I would say that this comment resolved itself since the BTreeSet is necessary for the RedecryptorReport.

@poljar poljar requested a review from Hywan November 12, 2025 12:45
@poljar
Copy link
Contributor Author

poljar commented Nov 13, 2025

I'm going to merge this since you approved it. If you feel like there's more to do here please shout and I'll handle it in a separate PR.

@poljar poljar force-pushed the poljar/event-cache/redecryptor branch from c3fb01d to 9508675 Compare November 13, 2025 11:05
@poljar poljar enabled auto-merge November 13, 2025 11:05
@poljar poljar merged commit 4fbc83a into main Nov 13, 2025
51 checks passed
@poljar poljar deleted the poljar/event-cache/redecryptor branch November 13, 2025 11:19
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.

3 participants