Skip to content

feat(event cache): process room updates concurrently #5426

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

Closed
wants to merge 1 commit into from

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Jul 21, 2025

This should improve latency of event cache updates in general, especially for massive initial sync responses (which may include many many rooms).

This should improve latency of event cache updates in general,
especially for massive initial sync responses (which may include many
many rooms).
@bnjbvr bnjbvr requested a review from a team as a code owner July 21, 2025 10:53
@bnjbvr bnjbvr requested review from poljar and removed request for a team July 21, 2025 10:53
Copy link

codecov bot commented Jul 21, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 88.87%. Comparing base (165ec9d) to head (3abf5a9).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/matrix-sdk/src/event_cache/mod.rs 50.00% 2 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5426      +/-   ##
==========================================
+ Coverage   88.85%   88.87%   +0.02%     
==========================================
  Files         333      333              
  Lines       91244    91256      +12     
  Branches    91244    91256      +12     
==========================================
+ Hits        81072    81103      +31     
+ Misses       6348     6326      -22     
- Partials     3824     3827       +3     

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

Copy link
Contributor

@poljar poljar left a comment

Choose a reason for hiding this comment

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

Performance improvements without numbers make me raise an eyebrow, but ok it's one of the simpler changes.

@bnjbvr
Copy link
Member Author

bnjbvr commented Jul 22, 2025

Annnnnnnnnnnnnnnnnnnd it's not a speedup, for reasons I can't fathom (cross-process lock contention? some other lock contention? benchmark doesn't do what we think it does?), and I don't have much time to investigate unfortunately, having to pivot to more oriented feature work.

For posterity, the benchmark added in #5435 shows the following perf diff, with this patch:

reading/handle_room_updates/sqlite store/1
                        time:   [2.2372 ms 2.4769 ms 2.6958 ms]
                        thrpt:  [370.95  elem/s 403.73  elem/s 446.98  elem/s]
                 change:
                        time:   [-20.865% -13.429% -4.3047%] (p = 0.01 < 0.05)
                        thrpt:  [+4.4983% +15.512% +26.366%]
                        Performance has improved.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) high mild
reading/handle_room_updates/sqlite store/10
                        time:   [44.909 ms 46.289 ms 47.953 ms]
                        thrpt:  [208.54  elem/s 216.03  elem/s 222.67  elem/s]
                 change:
                        time:   [-9.6624% +0.9193% +15.623%] (p = 0.91 > 0.05)
                        thrpt:  [-13.512% -0.9109% +10.696%]
                        No change in performance detected.
Found 2 outliers among 10 measurements (20.00%)
  1 (10.00%) low mild
  1 (10.00%) high severe
Benchmarking reading/handle_room_updates/sqlite store/100: Warming up for 3.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 5.2s.
reading/handle_room_updates/sqlite store/100
                        time:   [484.03 ms 496.08 ms 505.25 ms]
                        thrpt:  [197.92  elem/s 201.58  elem/s 206.60  elem/s]
                 change:
                        time:   [+56.456% +65.016% +74.717%] (p = 0.00 < 0.05)
                        thrpt:  [-42.765% -39.400% -36.084%]
                        Performance has regressed.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) low mild
Benchmarking reading/handle_room_updates/sqlite store/1000: Warming up for 3.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 69.8s.
reading/handle_room_updates/sqlite store/1000
                        time:   [4.1170 s 4.1930 s 4.2634 s]
                        thrpt:  [234.56  elem/s 238.49  elem/s 242.90  elem/s]
                 change:
                        time:   [+41.880% +45.468% +49.428%] (p = 0.00 < 0.05)
                        thrpt:  [-33.078% -31.256% -29.518%]
                        Performance has regressed.
Benchmarking reading/handle_room_updates/sqlite store/10000: Warming up for 3.0000 s^C⏎

@bnjbvr bnjbvr closed this Jul 22, 2025
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