Page MenuHomePhorge

Make tryDecryptEvents() use and update Room::undecryptedEvents
ClosedPublic

Authored by tusooa on Jun 24 2024, 7:23 PM.
Tags
None
Referenced Files
F30238: D71.1726893362.diff
Thu, Sep 19, 9:36 PM
F30232: D71.1726893086.diff
Thu, Sep 19, 9:31 PM
Unknown Object (File)
Fri, Sep 13, 6:03 PM
Unknown Object (File)
Sat, Sep 7, 5:43 PM
Unknown Object (File)
Wed, Sep 4, 6:31 PM
Unknown Object (File)
Mon, Sep 2, 6:38 PM
Unknown Object (File)
Mon, Sep 2, 3:47 PM
Unknown Object (File)
Mon, Sep 2, 3:46 PM
Subscribers
None

Details

Summary

The original way is to go and check every event in a room to see whether they can be decrypted. Now that we have a map from session id to a list of undecrypted event ids, this commit provides two optimizations:

  1. It only needs to check undecrypted events, which is sparse compared to the whole timeline.
  2. It checks the existence of the session id, and if it does not exist, we do not try to decrypt the events with that session id. We expect this to further decrease the number of trials needed by at least the magnitude of 10 in one-on-one rooms (100 messages to rotate sessions, so assuming 10 devices per person, it's on average 10 messages per session id).

The benchmark results ( https://iron.lily-is.land/T20 ) show that the new method will give <200ms performance per call even on extremely large and infeasible data sets, compared to ~4.4s for the original, sequential method. (For reference, the medium set is already pretty large (total of 50k events in encrypted rooms))

In the future, when we immerify kazvcrypto, we can use diff on the map of megolm sessions to further reduce the checks needed by checking only new events and session ids that have been changed.

Type: fix

BUG: https://iron.lily-is.land/T20

Test Plan

Verify that all tests pass. Build kazv against this. Verify that you can still send and receive encrypted messages.

Diff Detail

Repository
rL libkazv
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

For reference, I used to get ~1s delay between sending a message (from another account) and getting a notification on my main account. It is now almost instantaneous.

Harbormaster returned this revision to the author for changes because remote builds failed.Jun 24 2024, 7:55 PM
Harbormaster failed remote builds in B102: Diff 152!
This revision is now accepted and ready to land.Jul 3 2024, 5:59 PM