-
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
perf: remove getSearchText function #46409
perf: remove getSearchText function #46409
Conversation
Backlinking to #45528 |
@mkhutornyi Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
if (personalDetail.login) { | ||
// The regex below is used to remove dots only from the local part of the user email (local-part@domain) | ||
// so that we can match emails that have dots without explicitly writing the dots (e.g: fistlast@domain will match first.last@domain) | ||
// More info https://github.com/Expensify/App/issues/8007 |
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.
no need to link this old issue anymore?
if (isThread) { | ||
const title = ReportUtils.getReportName(report); | ||
const chatRoomSubtitle = ReportUtils.getChatRoomSubtitle(report); | ||
|
||
Array.prototype.push.apply(searchTerms, title.split(/[,\s]/)); | ||
Array.prototype.push.apply(searchTerms, chatRoomSubtitle?.split(/[,\s]/) ?? ['']); | ||
} else if (isChatRoomOrPolicyExpenseChat) { | ||
const chatRoomSubtitle = ReportUtils.getChatRoomSubtitle(report); | ||
|
||
Array.prototype.push.apply(searchTerms, chatRoomSubtitle?.split(/[,\s]/) ?? ['']); | ||
} |
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.
We had made threads searchable in #19117.
Please make sure that this removal doesn't cause regression.
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.
Overall it looks pretty good, but I'm having trouble tracking all the changes. Could you please explain a bit more about why it's ok to remove this function, how we can be sure it's not used anywhere, and provide an overview of how and why the tests were changed?
// Then we expect to have the personal detail with period filtered | ||
expect(results.recentReports.length).toBe(1); | ||
expect(results.recentReports[0].text).toBe('The Flash'); | ||
}); | ||
}); |
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.
The getSearchOptions function is still in use, could you please explain why it's ok to remove these tests?
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 see you added some tests at the bottom which look similar, but again I'm having trouble determining what has changed. Maybe with more context it will be clear to me.
hi @neil-marcellini, let me give you some background here. For the last couple of months I was working on optimizing search lists. The main bottlenecks here were:
For heavy loaded accounts, with thousands of reports and personal details, the total execution time for The actions we took were:
Since recently we migrated all the lists to the filtering, we should be safe to get rid of generating search text for options. Lists like Category, Tags, or Tag are still using Since removing |
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.
Ok thanks for explaining. The code looks good. Hopefully we didn't miss anything and there are no regressions.
@mkhutornyi please DM me on Slack when you finish your review and it's ready to merge. |
@mkhutornyi could you please take a look on this PR when you have a moment? Thanks! |
Just to put this PR into more context, the estimated gain for this is a major speedup in how the Chat Finder page operates on bigger accounts. Generally each interaction should be much snappier as we're stripping down ~40% of the existing compute time for generating the list of results. |
Bumped the C+ in Slack here. If he's too busy we can get someone else. |
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid.mp4Android: mWeb Chromemchrome.mp4iOS: Nativeios.moviOS: mWeb Safarimsafari.movMacOS: Chrome / Safariweb.movMacOS: Desktopdesktop.mov |
Looking good so far. Still testing with some more accounts |
@mkhutornyi thanks for diving into this, I'm hoping we can get this one merged today 🤞 |
src/libs/OptionsListUtils.ts
Outdated
@@ -2440,7 +2368,7 @@ function formatSectionsFromSearchTerm( | |||
// This will add them to the list of options, deduping them if they already exist in the other lists | |||
const selectedParticipantsWithoutDetails = selectedOptions.filter((participant) => { | |||
const accountID = participant.accountID ?? null; | |||
const isPartOfSearchTerm = participant.searchText?.toLowerCase().includes(searchTerm.trim().toLowerCase()); | |||
const isPartOfSearchTerm = getPersonalDetailSearchTerms(participant).join(' ').toLowerCase().includes(searchTerm.trim().toLowerCase()); |
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.
Can we move searchTerm.trim().toLowerCase()
to outside of the filter
? It seems redundant and we can potentially save some ms here.
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.
yep nice catch! No need to transform it each time
resolved comment & updated with main |
🚀 Deployed to staging by https://github.com/neil-marcellini in version: 9.0.17-0 🚀
|
🚀 Deployed to production by https://github.com/marcaaron in version: 9.0.17-2 🚀
|
2 similar comments
🚀 Deployed to production by https://github.com/marcaaron in version: 9.0.17-2 🚀
|
🚀 Deployed to production by https://github.com/marcaaron in version: 9.0.17-2 🚀
|
Details
Since all search pages are migrated to
filterOptions
now, we are able to remove usage ofgetSearchText
fromcreateOption
to speed up the time of building option list.Additionally, all tests for search were migrated to
filterOptions
.Removing
getSearchText
speeds up creating option list by around 40%. In the context of a trace provided for a linked issue, it reduces accumulatedcreateOption
time from 5.7s to 4s (~42% improvement)Fixed Issues
$ #45528
PROPOSAL:
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
ANDROID.mov
Android: mWeb Chrome
ANDROID-WEB.mov
iOS: Native
IOS.mov
iOS: mWeb Safari
IOS-WEB.mov
MacOS: Chrome / Safari
WEB.mov
MacOS: Desktop
DESKTOP.mov