Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Reward users for using stable ordering in their room list - #5047

Merged
turt2live merged 9 commits into
developfrom
travis/perf3
Jul 24, 2020
Merged

Reward users for using stable ordering in their room list#5047
turt2live merged 9 commits into
developfrom
travis/perf3

Conversation

@turt2live

Copy link
Copy Markdown
Member

This is probably best reviewed commit-by-commit, however a summary small novel explaining the theory is included here.

This optimizes the path for room list renders by ensuring that the scope of those renders is limited to only what is absolutely required. Users with a stable room list ordering will see the most benefit of this change, however large accounts with the activity & unread first options selected will see some gain too. Users with stable ordering will see the most benefit as they have the highest chance of getting updates to their rooms which are out of view or can be no-oped (no order change means we don't need to remount the entire sublist).

Larger accounts (particularly those with activity sorting and unread first enabled) will still see a hit for a delta in their room list, but changes which don't reorder their list should be a lot better. Due to account size this is expected to be relatively rare though: it is more likely that an argument will break out in a room and cause it to stay in the same position at the top of the room list, reducing the impact of renders. The happy paths for larger accounts are still improved (~100ms in gains in my testing, all told) though we are reaching diminishing returns on handling this use case. Large accounts are still recommended to show as little rooms as possible to rely on filtering instead.

However, this regresses filtering slightly in that it now can take 2x as long on the initial filter, with subsequent iterations being a whole lot faster. This is expected to be improved in a later commit.

This cuts the render time in half (from ~448ms to ~200ms on my account) per received event, as we're no longer re-mounting the entire room list and instead just the section(s) we care about.
Any time we though that the room list had to re-render we were dynamically creating a new addRoomFn, which would signal to the sublist that it needed to re-render. 

The only reason we wrap the function from the aesthetics is to provide theoretical tiling/multiaccount support through use of different dispatchers, however considering that's not a reality yet we can just use a default dispatcher when none is supplied.
We can ignore off-screen updates, so do that. See diff for more details on what we're doing.
In 7b97c30 we reduced the RoomList updates to just added/removed sublists, but didn't consider that we might also have to handle lengths of those sublists changing enough for us to fix the sticky headers.
In 9969b01 we stopped updating the sublist whenever we felt like it, which indirectly froze message previews for room tiles (badges, unread state, etc were unaffected because that is managed by a different store). To fix this, we simply have to listen for changes and perform an update.
... because it's faster. Also we don't need to diff the array here.
@turt2live
turt2live requested a review from a team July 24, 2020 04:39
@jryans

jryans commented Jul 24, 2020

Copy link
Copy Markdown
Collaborator

However, this regresses filtering slightly in that it now can take 2x as long on the initial filter, with subsequent iterations being a whole lot faster. This is expected to be improved in a later commit.

How far away is that later commit? Something that will come before the next release?

@turt2live

Copy link
Copy Markdown
Member Author

Should be today, if not Monday. Small/medium accounts won't even notice, just the large accounts that opted to show massive numbers of rooms.

@jryans jryans left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me, let's make sure to restore filtering perf before release though. 😄

@turt2live
turt2live requested a review from jryans July 24, 2020 16:38
@turt2live

Copy link
Copy Markdown
Member Author

@jryans can I get a quick look at the fixes for the e2e tests? They're a bit more involved.

Comment thread src/components/views/rooms/RoomList.tsx Outdated
Co-authored-by: J. Ryan Stinnett <jryans@gmail.com>
@turt2live
turt2live merged commit 57a5b47 into develop Jul 24, 2020
@turt2live
turt2live deleted the travis/perf3 branch July 24, 2020 17: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