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

[HOLD for payment 2023-09-29] [Performance] Improve SidebarLinks by caching getOrderedReportIDs #25467

Closed
mountiny opened this issue Aug 18, 2023 · 24 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Task

Comments

@mountiny
Copy link
Contributor

mountiny commented Aug 18, 2023

Coming from here

[Performance] Improve SidebarLinks:

Problem

Now all the Records to show on LHN are being calculated multiple times and the logic to fill it is complex, this one is a bit trickier to solve but I think it worth it

Solution

Summary

getOrderedReportIDs is a complex function that would be good to re-architecture.
Applying just caching like I did, isn’t the full solution, it gives me a good number to know if worth taking the time to improve it, and even if we aim to get ~40% to ~50% of improvement will be awesome

@mountiny mountiny self-assigned this Aug 18, 2023
@melvin-bot melvin-bot bot added the Overdue label Aug 21, 2023
@mountiny mountiny added Weekly KSv2 and removed Daily KSv2 labels Aug 21, 2023
@melvin-bot melvin-bot bot removed the Overdue label Aug 21, 2023
@mountiny
Copy link
Contributor Author

Asking in callstack room who will take these on

@waterim
Copy link
Contributor

waterim commented Aug 22, 2023

Hello, Im Artem from Callstack and would like to help with this one

@mountiny mountiny added Daily KSv2 and removed Weekly KSv2 labels Aug 23, 2023
@mountiny
Copy link
Contributor Author

Making this daily as the getOrderedReportIDs is one of the main offenders when it comes to performance for accounts with thousands reports

@mountiny
Copy link
Contributor Author

@waterim What are the next steps here?

@melvin-bot melvin-bot bot removed the Overdue label Aug 28, 2023
@waterim
Copy link
Contributor

waterim commented Aug 28, 2023

@mountiny will update you tomorrow, mostly performance here will be improved with caching, because just 1 filter in this function is taking 90% of the whole time and its impossible to optimize this one significantly, but caching is saving a lot of time.
One more thing I just started: removing some unnecessary sorts, after a discussion in Slack.
Also removing lodash with underscore and optimising the util function shouldReportBeInOptionList for filtering all this sidabar links

@mountiny
Copy link
Contributor Author

thanks for an update

@melvin-bot melvin-bot bot added the Overdue label Aug 30, 2023
@mountiny
Copy link
Contributor Author

Any updates here?

@melvin-bot melvin-bot bot removed the Overdue label Aug 31, 2023
@waterim
Copy link
Contributor

waterim commented Aug 31, 2023

@mountiny yes, have a progress, will open a PR today

@waterim
Copy link
Contributor

waterim commented Aug 31, 2023

@mountiny My update:
I added caching, improved the code base with removing undrescore and lodash.
But one tricky heavy thing still here, I had few calls with Eduardo and playing with a kind of "leetcode" trying to optimise the filter function which is taking another filter function and has n^2 complexity.
For now we have this filter:
const reportsToDisplay = Object.values(allReportsDict).filter((report) => ReportUtils.shouldReportBeInOptionList(report, currentReportId, isInGSDMode, betas, policies, allReportActions, true), );
And shouldReportBeInOptionList function has:
const lastVisibleMessage = ReportActionsUtils.getLastVisibleMessage(report.reportID);
And this lastVisibleMessage calculation is taking 0.2ms for each iteration(which is really heavy for a filtering)
And Im trying to optimise somehow the way we are getting lastVisibleMessage here

@mountiny
Copy link
Contributor Author

thanks for the update

@mountiny
Copy link
Contributor Author

mountiny commented Sep 4, 2023

Waterim has a PR up, @waterim do you think it will be ready for a review soon? I could make an adhoc build for testing

@melvin-bot melvin-bot bot removed the Overdue label Sep 4, 2023
@mountiny
Copy link
Contributor Author

mountiny commented Sep 6, 2023

Thanks for an update

@mountiny mountiny moved this from Todo to LOW in [#whatsnext] #quality Sep 7, 2023
@mountiny mountiny moved this from LOW to CRITICAL in [#whatsnext] #quality Sep 7, 2023
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Sep 20, 2023
@melvin-bot melvin-bot bot changed the title [Performance] Improve SidebarLinks by caching getOrderedReportIDs [HOLD for payment 2023-09-29] [Performance] Improve SidebarLinks by caching getOrderedReportIDs Sep 22, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 22, 2023

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Sep 22, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 22, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.72-11 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-09-29. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

For reference, here are some details about the assignees on this issue:

  • @waterim does not require payment (Contractor)

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Sep 29, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

@mountiny, @waterim Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@mountiny mountiny added the Bug Something is broken. Auto assigns a BugZero manager. label Oct 2, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

Triggered auto assignment to @alexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@mountiny
Copy link
Contributor Author

mountiny commented Oct 2, 2023

No checklist required, this is a performance improvement

@parasharrajat is due $500 for internal review

@melvin-bot melvin-bot bot removed the Overdue label Oct 2, 2023
@alexpensify
Copy link
Contributor

Here is the payment summary:

  • External issue reporter - N/A
  • Contributor that fixed the issue - N/A
  • Contributor+ that helped on the issue and/or PR - @parasharrajat $500

Upwork Job: N/A

*If applicable, the bonuses will be applied on the final payment

Extra Notes regarding payment: See the notes here - #25467 (comment)

@parasharrajat please request a payment in Chat and then we can close this out. Thanks!

@alexpensify
Copy link
Contributor

Ok, going to close out here.

@github-project-automation github-project-automation bot moved this from CRITICAL to Done in [#whatsnext] #quality Oct 4, 2023
@parasharrajat
Copy link
Member

Payment requested as per #25467 (comment)

@JmillsExpensify
Copy link

$500 payment approved for @parasharrajat based on BZ summary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Task
Projects
Development

No branches or pull requests

5 participants