-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[Performance] Typing in search is very laggy for big accounts #46591
Comments
Auto-assigning issues to engineers is no longer supported. If you think this issue should receive engineering attention, please raise it in #whatsnext. |
cc @sakluger (feel free to assign me as I (or someone from my team) will work on this ticket!) |
Just started working on this issue. I can see that I can kinda reproduce the lag if I enable lower performance settings in chrome (basically bringing my Cpu closer to the one the customer had). Working on ideas for improving the performance here! |
Created a PR that adds performance timings, so we can track upcoming performance improvements better: |
Okay, I have a proposal for a solution moving forward: Highlevel solution: use a trie structure for searchRight now our search data structure + search algorithm aren't really efficient. We loop over every item performing multiple comparison operations. We can make this way more efficient by using a trie structure and prefix search. Performance gainsI ran a test with the customers onyx data, right now only focusing on searching through the personal details.
So, right now this user on mobile will have a dead JS thread for ~300ms when typing in the search (dropping 18 frames), while with a trie, its just ~0.5ms, so no frames dropped really.
Changes needed / roadmap
CaveatsRight now building the trie takes some time and a fair amount of memory. I want to experiment a bit more using other DS such as generalised suffix tree or suffix arrays, and see which one works best! |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.17-2 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-08-14. 🎊 For reference, here are some details about the assignees on this issue:
|
Started a discussion here how we want to move forward technically: https://expensify.slack.com/archives/C05LX9D6E07/p1723209631007999 |
No payment required for the above PR: |
I just opened a PR hat shows a PoC for using web workers for running the search, which will unblock the main thread: I am now seeking approval on this new technical design here. (Note: I am OOO for the rest of the week and will continue next week Monday 19.08) |
Moving to weekly to make Melvin happy, we can move it back next week. |
@hannojg any updates on this one? |
It has been discussed here that our first proposal to offload the work to a different thread has been postponed (as we want to stay single threaded as long as possible). We are now working on a new proposal to use a more efficient data structure and a very fast search algorithm. Will post the proposal and a PoC today/trmrw. |
I asked for updates in the main tracking issue: #46595 |
Looks like we have a WIP PR that will speed up search by 2456x. |
🤯 that's sick! |
Looks like the draft PR is coming along! I see commits and reviews. |
I am back from OOO and working on it - expect to have a reviewable PR by tmrw! |
Status update:
Future Improvements: Building the tree can take some time on lower end devices (taking in millisecond range here - will get definite numbers soon). As an optimisation we could store the search tree in mmkv using array buffers. I believe this to be a really good optimisation for lower end mobile devices - but i don't want to convolute the current PR and will open a follow up ticket. (Additionally i am trying to see how the construction of the tree can be further improved) TL;DR: Very positive to have the PR ready and tested by TMRW! |
Status update:
|
PR is ready for review now! Whats missing in the current PR is to save the created "FastSearch" (tree) instance to a context, so it can be reused (so that we don't need to recreate the tree from scratch every time our personal details / reports. change). |
This is exciting, thanks for the updates @hannojg! I can't wait to see these improvements go live, it'll be a big win. |
Nice. Just catching up after OOO, but looks really impressive overall! |
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
What performance issue do we need to solve?
On a very big account typing in search for the first time is incredibly laggy, see recording. The user is continuously trying to type but the application is dropping so many frames that the text is only updated in jumps:
slow_search.mov
What is the impact of this on end-users?
Very slow and frustrating search experience. Borderline functional.
List any benchmarks that show the severity of the issue
The customer shared a profile trace with us:
Firefox 2024-07-25 10.42 profile.json.gz
(note: the trace also contains other test cases as well)
The customer had ~15k reports loaded in onyx when these tests were conducted, although in focus mode only 6 chats were displayed.
Proposed solution (if any)
None yet, I will go through the profile and see what can be optimised, what exactly caused those lags.
List any benchmarks after implementing the changes to show impacts of the proposed solution (if any)
not available yet
Platforms:
Which of our officially supported platforms is this issue occurring on?
Version Number: v9.0.11-5
Reproducible in staging?: not tested
Reproducible in production?: yes
Email or phone of affected tester (no customers): customer
Logs: See performance file
Notes/Photos/Videos: See attached video
Expensify/Expensify Issue URL: n/a
Issue reported by:@hannojg
Slack conversation:https://expensify.slack.com/archives/C05LX9D6E07/p1721919928992729
View all open jobs on Upwork
The text was updated successfully, but these errors were encountered: