This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
Speed up room unread checks by not hitting the SettingsStore so often #2339
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This was noticed as a problem after
Unread.doesRoomHaveUnreadMessages
started being called a lot more frequently. Down the call stack,shouldHideEvent
is called which used to call into theSettingsStore
frequently, causing performance issues in many cases. TheSettingsStore
tries to be as fast as possible, however there's still code paths that make it less than desirable to use as the first condition in an AND condition. By not hitting theSettingsStore
so often, we can shorten those code paths.As for how much this improves things, I ran some profiling before and after this change. This was done on my massive 1200+ room account. Before it was possible to see nearly 2 seconds spent generating room lists where 20-130ms per room was spent figuring out if the room has unread messages. Afterwards, the room list was generating within ~330ms and each unread check taking 0-2ms. There's still room for improvement on generating the room list, however the significant gains here seem worth it.
This is almost certainly a regression accidentally introduced by #2330 (which makes this something like the third or fourth speed regression introduced by the pinning options, sadly).