[Do Not Merge] perf: batch cold-cache pre-warm in mergeCollectionWithPatches via multiGet#91585
Draft
elirangoshen wants to merge 3 commits into
Draft
Conversation
Bumps react-native-onyx to elirangoshen/perf/mergeCollection-multiGet-prewarm HEAD (731fe957), which stacks on top of Expensify#787 (cache-first mergeCollectionWithPatches) and adds a cold-cache pre-warm optimization: - Fast path (every existingKey is in cache): skip pre-warm entirely. Preserves the original promise-chain depth so subscriber-callback timing is unchanged for warm-cache merges (the common case). - Slow path (any existingKey is a cache miss): use Storage.multiGet to batch the missing keys into a single storage round-trip, instead of N parallel Storage.getItem calls. Net runtime effect: same correctness, fewer storage operations on cold-cache merges, same broadcast timing for warm-cache merges. This branch also drops the now-obsolete `react-native-onyx+3.0.73.patch` (the canonical upstream revert it implemented landed in Onyx PR Expensify#785, which is already part of the pinned SHA). Not for merge -- branch is for performance verification only.
Wraps applyHTTPSOnyxUpdates in a Sentry span via the existing @libs/telemetry/activeSpans helper so we can measure local Onyx-update processing time per API response, isolated from network latency. Cold-cache mergeCollection batches dominate this duration during OpenApp / ReconnectApp / Search, so this span is a clean A/B-test signal for mergeCollectionWithPatches changes (cache-first ordering and multiGet pre-warm). Span attributes: command, onyx_data_count, success_data_count, failure_data_count. Local console output via the helper: [Sentry][OnyxUpdates.applyHTTPSOnyxUpdates:OpenApp:<id>] Ending span (Xms) Not for merge -- perf-test instrumentation only.
…ions Updates the package.json pin from Expensify/react-native-onyx#731fe957 to callstack-internal/react-native-onyx#c1be5731. The new SHA brings in the 5 mergeCollection pre-warm regression tests added on top of the original perf change, so the bundled build matches the test names referenced in PR #5's Manual Tests section. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
|
41 tasks
42 tasks
Contributor
|
Contributor
Author
Hi there has been misunderstood, this it not pr to open, as its only for testing the other onyx change, so this is only companion pr, thats why I left it as draft :) Ill modify the pr body , screenshots are in the onyx pr |
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
Companion App PR for callstack-internal/react-native-onyx#5.
Two changes:
Repoint
react-native-onyxpin tocallstack-internal/react-native-onyx#c1be5731. The onyx-side change introduces a hybrid pre-warm strategy formergeCollectionWithPatches:Promise.resolve()to preserve the original promise-chain depth and subscriber-callback timing.multiGetto batch the missing keys into oneStorage.multiGetround-trip instead of N parallelget()calls.See the onyx PR for the full motivation, code, and 5 automated regression tests.
Add
OnyxUpdates.applyHTTPSOnyxUpdatesSentry span. Measures the timemergeCollectionWithPatchesactually saves on real workloads (LHN refresh, OpenApp response, Pusher updates, search refreshes). Lets us A/B the bundled pin againstmainin staging.Fixed Issues
$ #90634
PROPOSAL: N/A (performance improvement, not a proposal-driven issue)
Automated Tests
Tests
End-to-end verification on web. The onyx PR's Manual Tests section has the full step-by-step (DevTools storage-counter instrumentation, IDB-delete simulation, etc.); the summary below is what to actually run against this App pin.
Setup
elirangoshen/perf/mergeCollection-multiGet-prewarm(this branch).npm installunder Node 20.20.0,npm run web.Slow path — cold-cache batched read (core perf claim)
OnyxDBwhile running (do not reload).Onyx.updatecontaining aMERGE_COLLECTIONop — open Search RHP, switch workspaces, or wait for a PusherreportActions_update.Storage.multiGetcovering the missing keys; zero individualStorage.getItemcalls during pre-warm. Onmainyou'd see N parallelgetItemcalls instead.Fast path — warm-cache no-op
MERGE_COLLECTIONflow.multiGet, zerogetItemcalls during pre-warm. Subscriber receives a single merged broadcast with no transientundefined/empty render flicker.Functional smoke (no regression in
mergeCollection-driven flows)Cold-cache merge correctness
MERGE_COLLECTIONagainst one of those keys before the LHN hydrates it.Sentry span verification
[Sentry][...] Ending spanconsole logs), trigger a couple ofOnyx.updateflows.OnyxUpdates.applyHTTPSOnyxUpdatesspans appear withdurationMspopulated, ready for A/B comparison againstmainin staging.Offline tests
Storage-failure regression (carry-over from #91160 / onyx #787)
OnyxDB. Do not reload.MERGE_COLLECTIONaction.Standard offline path: toggle the network off, send a chat message, mark-all-as-read, switch workspaces — verify optimistic updates render immediately and reconcile correctly when the network is restored.
QA Steps
Same as Tests. Run the Functional smoke block on each platform to confirm no regression in
mergeCollection-driven flows (LHN hydration, chat send, mark-all-as-read, search filter, hold/unhold, FAB submit, workspace switch).PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))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.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: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari