-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Optimize report ordering in the LHN #10784
Conversation
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.
Updated and ready for another review!
focusedIndex={_.findIndex(this.state.orderedReports, ( | ||
option => option.reportID === activeReportID | ||
focusedIndex={_.findIndex(this.orderedReports, ( | ||
option => option.reportID.toString() === this.props.currentlyViewedReportID.toString() |
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.
option.reportID
comes from Onyx, where it's stored as a number, because PHP is sending it as a number. The second one is already a string, so I've removed the unnecessary .toString()
from it.
This will ultimately be cleaned up in https://github.com/Expensify/Expensify/issues/227425
@@ -158,18 +158,37 @@ Onyx.init({ | |||
}); | |||
|
|||
function getDefaultRenderedSidebarLinks() { | |||
class ErrorBoundary extends React.Component { | |||
// Error boundaries have to implement this method. It's for providing a fallback UI, but | |||
// we don't need that for unit testing, so this is basically a no-op. |
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.
I've added a big code comment to explain the why
behind why this is necessary.
I haven't had the time to test this on all platforms, but I would like to do that before this is merged. Maybe I'll have the time to do this tomorrow. |
Tested on iOS and Desktop. Seems to be working very well. |
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.
Changes are looking good to me. I'd be curious to see some before and after snapshots to get a better idea of which changes impacted performance the most, but that is NAB.
I also think it would be good to distill any of the things we learned here and add them to the PERFORMANCE.md
doc with some tips on when some of the strategies used in this PR would be appropriate to use.
I also see these logs, which indicate that while it takes ~220ms on web to sort and filter the reports, it's taking almost 30 seconds on android.
|
Hm, OK. Same thing is happening on |
As I was doing some performance testing this morning, to get you snapshots of main vs. this branch, it's pretty interesting. This branch actually doesn't change much the rendering time of the LHN. BUT it achieves the same performance as main without having all of the memoized methods and the Where we're really going to see the performance gains is in #10800 |
I'm going to self merge since it's got a couple of reviews. This will let me move onto my next step of optimizing. The two failing tests are OK because there are no contributors involved with this one. |
@tgolen looks like this was merged without passing tests. Please add a note explaining why this was done and remove the |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Cherry-picked to staging by @francoisl in version: 1.2.0-3 🚀
@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes. Note: we had a conflict on the |
This is the first step in optimizing the ordering logic of the sidebar. It does these things:
setDerivedStateFromProps
and any other static methodsOptionsListUtils
so that it's very efficient and only doing the minimum amount of logic in the fastest wayFixed Issues
Part of #7948
Tests
Everything is covered by unit tests, but in general you need to test:
Screenshots
Web
Mobile Web
Desktop
iOS
Android