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

[$250] [Performance] MainDrawer re-renders unnecessarily reported by @vladamx #11447

Closed
5 tasks done
marcaaron opened this issue Sep 29, 2022 · 19 comments
Closed
5 tasks done
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Improvement Item broken or needs improvement. Reviewing Has a PR in review

Comments

@marcaaron
Copy link
Contributor

marcaaron commented Sep 29, 2022

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


What performance issue do we need to solve?

inefficient React component rendering

What is the impact of this on end-users?

slightly slower speeds to render a report

List any benchmarks that show the severity of the issue

Before

Timing:expensify.cash.switch_report.cold 222
Timing:expensify.cash.switch_report.cold 210
Timing:expensify.cash.switch_report.cold 222

Proposed solution (if any)

Prevent the Main drawer from re-rendering by only allowing it to re-render if we do not yet have the initial params.

List any benchmarks after implementing the changes to show impacts of the proposed solution (if any)

After

Timing:expensify.cash.switch_report.cold 176
Timing:expensify.cash.switch_report.cold 190
Timing:expensify.cash.switch_report.cold 175

Platform:

Where is this issue occurring?

  • Web
  • iOS
  • Android
  • Desktop App
  • Mobile Web

Version Number: 1.2.9-0
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
Upwork URL: https://www.upwork.com/jobs/~01c2ba78197b3488bc
Reported by: @vladamx

View all open jobs on Upwork

@marcaaron marcaaron added Engineering Daily KSv2 Improvement Item broken or needs improvement. labels Sep 29, 2022
@marcaaron
Copy link
Contributor Author

This was reported by @vladamx so I think we should give them first dib on this.

@marcaaron marcaaron added the External Added to denote the issue can be worked on by a contributor label Sep 29, 2022
@melvin-bot
Copy link

melvin-bot bot commented Sep 29, 2022

Triggered auto assignment to @trjExpensify (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Sep 29, 2022

Triggered auto assignment to Contributor-plus team member for initial proposal review - @rushatgabhane (External)

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 29, 2022
@melvin-bot
Copy link

melvin-bot bot commented Sep 29, 2022

Triggered auto assignment to @deetergp (External), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@melvin-bot melvin-bot bot changed the title [Performance] MainDrawer re-renders unnecessarily reported by @vladamx [$250] [Performance] MainDrawer re-renders unnecessarily reported by @vladamx Sep 29, 2022
@trjExpensify
Copy link
Contributor

Sounds good! Job is on Upwork here: https://www.upwork.com/jobs/~01c2ba78197b3488bc

@vladamx
Copy link
Contributor

vladamx commented Sep 30, 2022

@marcaaron Thank you for bringing this up! Hope we can do a whole suite of optimizations to improve perf in Expensify!

Intro

MainDrawerNavigator calculates initial report to open and therefore subscribes to reports which can change many times during the lifecycle of the app even though the data is only needed initially - on app launch.

Profiling done below is just for the use case when user is adding a message to any report where you can see the savings of around 120ms only for the add message to chat.

Greater savings are achieved if you take into account all mutations that can happen on reports.

Profiling - Before

Screenshot 2022-09-30 at 13 46 50

Screenshot 2022-09-30 at 13 46 37

Screenshot 2022-09-30 at 13 46 06

As you can see MainDrawer is re-rendered 3 times during adding a message to chat with a penalty of 3 * 42.5ms = 127.5ms

Profiling - After memoization on initialReport calculation

Screenshot 2022-09-30 at 13 51 34

Screenshot 2022-09-30 at 13 51 26

Screenshot 2022-09-30 at 13 51 15

3 x 0.5 ms = 1.5ms

So we achieved savings of 126ms of render time only for adding new message which is significant when you take into account how small render budget is.

@melvin-bot melvin-bot bot removed Help Wanted Apply this label when an issue is open to proposals by contributors Daily KSv2 labels Sep 30, 2022
@melvin-bot
Copy link

melvin-bot bot commented Sep 30, 2022

📣 @vladamx You have been assigned to this job by @marcaaron!
Please apply to this job in Upwork and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@melvin-bot melvin-bot bot added the Weekly KSv2 label Sep 30, 2022
@vladamx
Copy link
Contributor

vladamx commented Sep 30, 2022

Proposal sent to Upwork.

PR 1.10.2022

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Sep 30, 2022
@trjExpensify
Copy link
Contributor

Hired! 🎉

@vladamx
Copy link
Contributor

vladamx commented Oct 1, 2022

PR: #11506 (comment)

@melvin-bot melvin-bot bot added the Overdue label Oct 4, 2022
@trjExpensify trjExpensify added the Reviewing Has a PR in review label Oct 4, 2022
@melvin-bot melvin-bot bot removed the Overdue label Oct 4, 2022
@trjExpensify
Copy link
Contributor

PR is in active review.

@trjExpensify
Copy link
Contributor

C+ reviewed. Over to @deetergp now and we should be good to go!

@trjExpensify
Copy link
Contributor

Deployed to staging. Once it hits prod, the payout clock begins! 🎉

@vladamx
Copy link
Contributor

vladamx commented Oct 14, 2022

Am I eligible for reporting bonus as well?

@trjExpensify
Copy link
Contributor

Yep! When I go to pay you out, I'll add that.

@puneetlath puneetlath added the Bug Something is broken. Auto assigns a BugZero manager. label Oct 19, 2022
@rushatgabhane
Copy link
Member

@trjExpensify payment can be done for this issue #11506 (comment)

@trjExpensify
Copy link
Contributor

Yeah, interesting. Any idea why the title didn't update with the payment date?

@vladamx - paid + reporting bonus.
@rushatgabhane - sent you the offer.

@rushatgabhane
Copy link
Member

@tjferriss im not sure, but the cause must be intermittent

@trjExpensify
Copy link
Contributor

Gotcha. Alrighty, all settled up here. Thanks everyone! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Improvement Item broken or needs improvement. Reviewing Has a PR in review
Projects
None yet
Development

No branches or pull requests

6 participants