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.
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.
We had made threads searchable in #19117.
Please make sure that this removal doesn't cause regression.
neil-marcellini
left a comment
There was a problem hiding this comment.
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?
| expect(results.recentReports.length).toBe(1); | ||
| expect(results.recentReports[0].text).toBe('The Flash'); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
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.
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 |
neil-marcellini
left a comment
There was a problem hiding this comment.
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
| 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.
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.
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 🚀
|
| } | ||
|
|
||
| function getPersonalDetailSearchTerms(item: Partial<ReportUtils.OptionData>) { | ||
| return [item.participantsList?.[0]?.displayName ?? '', item.login ?? '', item.login?.replace(CONST.EMAIL_SEARCH_REGEX, '') ?? '']; |
Details
Since all search pages are migrated to
filterOptionsnow, we are able to remove usage ofgetSearchTextfromcreateOptionto speed up the time of building option list.Additionally, all tests for search were migrated to
filterOptions.Removing
getSearchTextspeeds up creating option list by around 40%. In the context of a trace provided for a linked issue, it reduces accumulatedcreateOptiontime from 5.7s to 4s (~42% improvement)Fixed Issues
$ #45528
PROPOSAL:
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.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