Skip to content
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

Merged
merged 2 commits into from
Dec 8, 2018

Conversation

turt2live
Copy link
Member

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 the SettingsStore frequently, causing performance issues in many cases. The SettingsStore 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 the SettingsStore 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).

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 the `SettingsStore` frequently, causing performance issues in many cases. The `SettingsStore` 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 the `SettingsStore` 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.
@turt2live turt2live requested a review from a team December 8, 2018 03:17
Copy link
Member

@dbkr dbkr left a comment

Choose a reason for hiding this comment

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

Lgtm. Maybe worth a comment here saying that the order is important.

@turt2live turt2live merged commit 7803158 into develop Dec 8, 2018
@turt2live turt2live deleted the travis/speed-up-room-list branch December 8, 2018 19:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants