You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$175] Performance: Cap cached Search snapshots at 25 using LRU eviction #106780
BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorReviewingHas a PR in reviewTask
Distinct Search queries persist separate snapshots in Onyx/IndexedDB across sessions. Quota-triggered eviction allows these to accumulate on web, duplicating large policy payloads and increasing storage and update work.
Proposed change
Keep at most 25 ordinary cached Search snapshots, evicting the least recently used.
Preserve snapshots for current, saved, and suggested searches outside that cap.
Prune existing oversized caches, not just newly created snapshots.
Remove evicted snapshots from both memory and persistent storage.
Acceptance criteria
Running more than 25 distinct queries evicts the least recently used eligible snapshots.
Revisiting a cached query refreshes its recency.
Evicted queries refetch correctly when reopened.
Current, saved, and suggested searches remain functional.
changed the title [-]Performance: Cap cached Search snapshots at 25 using LRU eviction[/-][+][$175] Performance: Cap cached Search snapshots at 25 using LRU eviction[/+]on Dec 1, 2026
Search creates a persistent snapshot for each distinct query hash, but there is no application-level snapshot count limit. Snapshots are eligible for storage-pressure eviction; that does not enforce a 25-entry cache.
Confidence: Medium — supported by code inspection; browser persistence and performance were not independently tested.
Supporting evidence
Search writes results to hash-specific snapshot keys: Search.ts:901–913.
Setup marks snapshots as evictable without specifying a count limit: setup/index.ts:47–57.
Onyx’s storage-pressure eviction is triggered by capacity errors, not by reaching 25 snapshots: OnyxUtils.ts:678–701.
This explains accumulation across sessions. It does not independently establish the magnitude of the storage or performance impact.
What changes do you think we should make in order to solve the problem?
Persist query-access order and refresh it on cached revisits, not just requests.
Keep the newest 25 ordinary snapshots, with current/saved/suggested snapshots excluded from that budget.
Reconcile existing snapshots at startup and whenever protection changes.
Delete complete evicted keys from memory and persistent storage.
Re-enforce the limit after delayed responses recreate snapshots.
The existing PR needs three acceptance-criteria decisions/corrections:
Existing implementation gaps
Saved/suggested protection has its own cap. The PR can evict unmounted pinned snapshots beyond a separate 25-entry budget—even when they still represent valid saved searches. That conflicts with the issue’s stated exemption. See SearchSnapshotCache.ts:23–30.
Legacy migration clears every snapshot. This includes cached current/saved/suggested results. Online refetch can restore them, but offline availability is lost. Preserve protected entries during reconciliation, or explicitly approve this one-time exception. See ClearUntrackedSearchSnapshots.ts:11–18.
Removing active protection does not trigger pruning. Closing a protected consumer can leave more than 25 ordinary snapshots until subsequent cache activity. Schedule reconciliation when protection is removed. See SearchSnapshotCache.ts:86–101.
Validation: Cover 26+ ordinary queries, cached revisits, 26+ saved searches, oversized-cache startup, reload persistence, offline preservation, unmount-triggered pruning, and delayed-response recreation. Verify deletion in both Onyx and IndexedDB, then reopen an evicted query online.
What alternative solutions did you explore? (Optional)
Quota-only eviction does not enforce the requested limit. Request-only pruning also misses cached accesses and startup reconciliation; a blanket cache reset sacrifices protected offline results.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/106780) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorReviewingHas a PR in reviewTask
Activity
expensify-chore-bot commentedon Dec 1, 2026
Current assignee @FitseTLT is eligible for the External assigner, not assigning anyone new.
[-]Performance: Cap cached Search snapshots at 25 using LRU eviction[/-][+][$175] Performance: Cap cached Search snapshots at 25 using LRU eviction[/+]expensify-chore-bot commentedon Dec 1, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022127795318824218900
MelvinBot commentedon Dec 1, 2026
Proposal
What is the root cause of that problem?
Search creates a persistent snapshot for each distinct query hash, but there is no application-level snapshot count limit. Snapshots are eligible for storage-pressure eviction; that does not enforce a 25-entry cache.
Confidence: Medium — supported by code inspection; browser persistence and performance were not independently tested.
Supporting evidence
This explains accumulation across sessions. It does not independently establish the magnitude of the storage or performance impact.
What changes do you think we should make in order to solve the problem?
Continue the existing fix: Cap cached Search snapshots at 25 with LRU eviction, rather than opening a duplicate implementation.
The policy should:
The existing PR needs three acceptance-criteria decisions/corrections:
Existing implementation gaps
Saved/suggested protection has its own cap. The PR can evict unmounted pinned snapshots beyond a separate 25-entry budget—even when they still represent valid saved searches. That conflicts with the issue’s stated exemption. See SearchSnapshotCache.ts:23–30.
Legacy migration clears every snapshot. This includes cached current/saved/suggested results. Online refetch can restore them, but offline availability is lost. Preserve protected entries during reconciliation, or explicitly approve this one-time exception. See ClearUntrackedSearchSnapshots.ts:11–18.
Removing active protection does not trigger pruning. Closing a protected consumer can leave more than 25 ordinary snapshots until subsequent cache activity. Schedule reconciliation when protection is removed. See SearchSnapshotCache.ts:86–101.
Validation: Cover 26+ ordinary queries, cached revisits, 26+ saved searches, oversized-cache startup, reload persistence, offline preservation, unmount-triggered pruning, and delayed-response recreation. Verify deletion in both Onyx and IndexedDB, then reopen an evicted query online.
What alternative solutions did you explore? (Optional)
Quota-only eviction does not enforce the requested limit. Request-only pruning also misses cached accesses and startup reconciliation; a blanket cache reset sacrifices protected offline results.
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/106780)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
view run