-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 2024-04-15] [Performance] Implement caching of list options #37878
Comments
can I be assigned to this issue? |
Update: I have opened a draft PR, I just need to adjust a few things tomorrow morning - e.g. add required comment for props etc. I am keeping an eye on #37909 as well, because whatever gets merged first, it will require some changes in the second PR. It should not be something time-consuming anyway. I also need to take care of a failing tests. I'll prepare a PR for opening once I finish all the work that is left. A quick demo of how cached options work on my Android device: Record_2024-03-13-12-22-27.1.mp4 |
Update: unit tests should be fixed now, I'm gonna take a look on reassure tests on Monday, this and some cleanup on branch are the only things left before it's ready for review |
PR #38207 has an ongoing C+ review |
Triggered auto assignment to @grgia, see https://stackoverflow.com/c/expensify/questions/7972 for more details. |
@grgia Since I reviewed the PR, can you assign me this issue? Thank you 😄 |
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results. If a regression has occurred and you are the assigned CM follow the instructions here. If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future. |
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results. If a regression has occurred and you are the assigned CM follow the instructions here. If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future. |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.60-13 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 2024-04-15. 🎊 For reference, here are some details about the assignees on this issue:
|
Issue is ready for payment but no BZ is assigned. @slafortune you are the lucky winner! Please verify the payment summary looks correct and complete the checklist. Thanks! |
Payment Summary
BugZero Checklist (@slafortune)
|
@hungvu193 - offer sent here -https://www.upwork.com/nx/wm/offer/101887481 |
I've just accepted. Thanks. |
Contributor: @TMisiukiewicz is from an agency-contributor and not due payment |
Problem
When opening the search page and calling getOptions function, which is responsible for generating a list of options based on specific parameters and conditions, it loops through all the reports and personal details. The most expensive function that is called on each item is createOption - it fills almost all the time of getOptions.
These calculations are done from scratch each time any search page utilizing getOptions is being opened. It means each time Search page is getting opened, user has to wait up to a few seconds to get a list of options. Additionally, the bigger input of getOptions is, the slower the function gets.
Solution
We can implement a solution where all available options are generated only once. They can be shared across all searchable lists, like Search page, New chat, Invite to workspace etc by using React Context. The only thing needed when opening the search page is actually filtering the list based on options currently passed to getOptions.
Options should be generated while opening any search screen for the first time. It means if the screen is opened for the first time, it would display a skeleton first and display options once they are generated, but every next time it will just filter options and display them almost instantly.
Options list will be updated automatically in the background whenever personal details or reports change. Since calling getOptions is costy, we should instead retrieve the updated report ID, create just a single option instead of generating all of them and update it in the options array.
Some results I was able to achieve with PoC:
1st opening of the Search Page: Before: ~4500ms → After: ~4500ms -> no change
2nd and each subsequent opening of the Search Page: Before: ~4500ms → After: ~380ms -> ~12x faster
Update of a single option in an option list: ~0.3ms
from: @TMisiukiewicz here
The text was updated successfully, but these errors were encountered: