-
Notifications
You must be signed in to change notification settings - Fork 332
perf: precompute the room notification modes only if push rules have changed #5621
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
base: main
Are you sure you want to change the base?
perf: precompute the room notification modes only if push rules have changed #5621
Conversation
…s have changed The room notification modes will only change when the push rules have changed; otherwise, recomputing them is a no-op, and only wastes time. Here's a distribution of the worst processing times under this method, as measured in multiverse with my personal account running (fresh, i.e. after an initial response) for a few minutes: Before: 0.001358279s 0.019668889s 0.030104444s 0.030376296s 0.048609819s 0.049683619s 0.054289813s 0.063690030s After: 0.000000385s 0.000000387s 0.000000410s 0.000000430s 0.000000438s 0.000000478s 0.000000487s 0.000000568s 0.010011267s The new distribution makes sense: the push rules event comes only once, in the initial response, so they're processed only once. Then, there's no need to process it ever again (in my session I've never changed the processing times), so it's almost instantaneous the subsequent times.
…sh rules have changed
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5621 +/- ##
==========================================
- Coverage 88.88% 88.87% -0.01%
==========================================
Files 348 348
Lines 96451 96460 +9
Branches 96451 96460 +9
==========================================
Hits 85730 85730
- Misses 6685 6693 +8
- Partials 4036 4037 +1 ☔ View full report in Codecov by Sentry. |
CodSpeed Performance ReportMerging #5621 will not alter performanceComparing Summary
|
continue; | ||
}; | ||
|
||
room.user_defined_notification_mode().await; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: an extra perf improvement would be to create the NotificationSettings
instance once (instead of once per call to user_defined_notification_mode()
), and use it to update all the room notification modes at once, instead of creating the NotificationSettings
(which loads the push rules from DB) once per room.
Also, I think it's still necessary to figure what are the newly joined rooms, and compute the user defined notification mode for those.
Not as simple as I imagined first, unfortunately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks. I am assuming this is already covered by adequate tests?
The room notification modes will only change when the push rules have changed; otherwise, recomputing them is a no-op, and only wastes time.
Here's a distribution of the worst processing times under this method, as measured in multiverse with my personal account running (fresh, i.e. after an initial response) for a few minutes:
Before:
0.001358279s
0.019668889s
0.030104444s
0.030376296s
0.048609819s
0.049683619s
0.054289813s
0.063690030s
After:
0.000000385s
0.000000387s
0.000000410s
0.000000430s
0.000000438s
0.000000478s
0.000000487s
0.000000568s
0.010011267s
The new distribution makes sense: the push rules event comes only once, in the initial response, so they're processed only once. Then, there's no need to process it ever again (in my session I've never changed the processing times), so it's almost instantaneous the subsequent times.
Found thanks to #5612