Repository navigation
perf: Request Search page data once per session instead of on every Spend focus - #108445
Draft
elirangoshen wants to merge 2 commits into
Draft
elirangoshen wants to merge 2 commits into
elirangoshen wants to merge 2 commits into
Conversation
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
…-once-per-session # Conflicts: # tests/unit/useSearchPageSetupTest.tsx
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation of Change
Every time the Spend page gets focus,
useSearchPageSetupcallsOpenSearchPage. On an account with many workspaces the response is large and doesn't change between calls. On one big account it holds about 6,000 workspaces (10.2 MB), and three calls in a row returned identical workspace data.Until #88994 the call ran once per session, because the Spend tab stays mounted. #88994 moved it into
useFocusEffectso Spend reloads its data after "Clear cache and restart". This PR keeps that, but skips the request when the data was already loaded in this session:OpenSearchPagenow sets a RAM-only flag,RAM_ONLY_HAS_FRESH_SEARCH_PAGE_DATA, in itssuccessData. This follows the same pattern asRAM_ONLY_HAS_FRESH_WALLET_DATA.Onyx.cleardrops RAM-only keys, so after a cache clear the next focus requests the data again.IS_SEARCH_PAGE_DATA_LOADED, which was removed in July because a failed request could leave Spend stuck loading.Measured on that big account (dev build, web, same session, old vs new behavior, 5 Spend opens each, medians):
OpenSearchPagedownloadProduction server logs for that account on one working day (08:00 to 18:00 UTC): 699
OpenSearchPagecalls, 7.4 GB downloaded, 25 minutes of server time.Fixed Issues
$
PROPOSAL:
Tests
OpenSearchPage.OpenSearchPagerequest is sent and the list loads.OpenSearchPagerequest is sent and the list still shows.OpenSearchPageis sent again and the Spend list loads (no endless skeleton).Unit tests:
tests/unit/useSearchPageSetupTest.tsx(new case: requests the data on focus only until it has loaded in this session, and again after a cache clear) andtests/unit/SearchActionsTest.ts(the success flag is only set in memory).Offline tests
OpenSearchPagehas loaded.OpenSearchPagerequest is sent when the connection returns.QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.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
Not recorded on this platform: the change is shared JS (one hook and one action), with no platform-specific code. Tested on web, see MacOS.
Android: mWeb Chrome
Not recorded on this platform: the change is shared JS (one hook and one action), with no platform-specific code. Tested on web, see MacOS.
iOS: Native
Not recorded on this platform: the change is shared JS (one hook and one action), with no platform-specific code. Tested on web, see MacOS.
iOS: mWeb Safari
Not recorded on this platform: the change is shared JS (one hook and one action), with no platform-specific code. Tested on web, see MacOS.
MacOS: Chrome / Safari