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

Improve RoomList render time when filtering #5874

Merged
merged 9 commits into from
Apr 21, 2021
Merged

Conversation

germain-gg
Copy link
Contributor

@germain-gg germain-gg commented Apr 15, 2021

Improves element-hq/element-web#14750
God speed unleashed when used with element-hq/element-web#16969

Benchmark below

  • Figure 1: After my improvements
  • Figure 2: Before my improvements

Screen Shot 2021-04-15 at 16 09 37

  • A few events were not cleaned up properly
  • Some work is done is the constructor when it could be offloaded at a later stage
  • Mounting and unmounting RoomSublist is quite expensive. It ends up being much cheaper to hide rather than unmounting it when empty. Trading a tiny bit of ram for faster filtering

@germain-gg germain-gg requested a review from a team April 15, 2021 15:39
Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

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

It also looks like there's failing end to end tests, which look like legitimate failures

Comment on lines +291 to +292
this.dispatcherRef = defaultDispatcher.register(this.onAction);
this.roomStoreToken = RoomViewStore.addListener(this.onRoomViewStoreUpdate);
Copy link
Member

Choose a reason for hiding this comment

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

is it actually more performant to move things to componentDidMount? Over the last couple years we've started using the constructor more and more, slowly getting rid of componentDidMount - putting aside arguments about whether that is correct behaviour, I'm curious if there's a performance impact.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It depends, generally speaking there can be small performance improvements when the component is rendered but not mounted

But in my opinion the real power of this is that you colocate all your event listeners, if you have some event listeners that you need to place on DOM elements, you will have to perform that in componentDidMount. And on top of that if it is immediatly followed by componentWillUnmount you're one step closer to remembering to clean up your listeners

It also helps in tests where you shallow render your components

Overall moving away from lifecycles makes sense, this is pretty much what the React team has been advocating for, but their solution seems to be using hooks instead

src/components/views/rooms/RoomSublist.tsx Outdated Show resolved Hide resolved
@turt2live
Copy link
Member

I'm not sure how to interpret the screenshot: it looks like we're spending more time in code?

Overall this looks sensible, but I am curious how it interacts with the tab indexing/accessibility. It'd also be good to get a comment somewhere in the code to say we deliberately keep the sublists rendered so we don't accidentally optimize it back out 😅

@germain-gg
Copy link
Contributor Author

I'm not sure how to interpret the screenshot: it looks like we're spending more time in code?

I've read my description again, and it is utterly confusing, the left figure is AFTER my improvements. and the right figure is BEFORE 👀

Jonathan (jboi) also took a recording and there, the left figure is BEFORE and the right figure is AFTER (sorry this is all very confusing)
Screen Shot 2021-04-15 at 19 49 20

Overall this looks sensible, but I am curious how it interacts with the tab indexing/accessibility.

Generally speaking screen readers will ignore everything that is display: none;

It'd also be good to get a comment somewhere in the code to say we deliberately keep the sublists rendered so we don't accidentally optimize it back out 😅

Will do 👍

@germain-gg germain-gg requested a review from turt2live April 19, 2021 15:22
Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

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

otherwise lgtm

test/end-to-end-tests/src/usecases/signup.js Show resolved Hide resolved
@germain-gg germain-gg merged commit 68fb9a7 into develop Apr 21, 2021
@germain-gg germain-gg deleted the gsouquet-room-events branch April 21, 2021 08:09
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