Repository navigation
perf(app): stay responsive with ~100k-row WAL histories - #25594
Merged
Merged
Conversation
…ries A phone holding ~92k WAL rows (90k synced history) froze for 1-2 s every few seconds while capturing: each flush published a new inventory list, and SyncProvider disposed and rebuilt WalDerivedViews over every row. WalDerivedViews.sync() now adopts a new snapshot with identity checks only: an append-only change is recognised with pointer comparisons, and full per-row derivation runs only for added or removed rows. Retained rows keep their bucket caches; a reorder renumbers and invalidates the order-sorted lists. Newest-first lists break timestamp ties by source order, so results never depend on update history. Also: cache Wal.id (cleared by its two setters), count pending disk WALs without copying the inventory, skip the live-proof key pass when nothing is pending, and skip the loaded-key set at startup when no capture rows wait. Local benchmark, 89k synced + 3.6k pending rows, debug JIT on a loaded host: per-update derived-view block 1.0-3.0 s -> 11-14 ms; construction ~1.4 s -> ~0.33 s. WAL status, files, retry, deletion and upload decisions are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… path Review follow-ups for the incremental derived views: the append fast path compared against the caller's list, which a caller could edit in place; keep a pointer copy instead. Tests pin the fast path, Wal.id invalidation on device/timerStart changes, and dispose comparison views promptly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Problem
A field phone holding 92,763 WAL rows (90,889 synced history, ~3.6k pending) froze for 1.2–2.3 s every few seconds and hit "stopped responding", even in airplane mode with the pendant off. Its debug log shows
mobile_render_diagnosticworst frames of 1.2–2.3 s alongside a WAL flush every ~5–10 s.Each flush publishes a new inventory list.
SyncProvider.derivedWals(and theWalDerivedSyncViewsstand-in mixin) then disposed and reconstructedWalDerivedViewsover every row. That is a 10-bucket_apply, aHashSetper id and a listener registration for each of ~92k rows, all on the UI isolate.Fix
WalDerivedViews.sync(rows)adopts a new snapshot in place:Construction is cheaper:
HashSet._ViewEntryreuses onesyncDisplayStateread for both the display state and the attention bucket.Newest-first lists break
timerStartties by source order, so selectors never depend on update history. Dart's sort is not stable, and tie order was already history-dependent before this change.Wal.idis cached and cleared by thedevice/timerStartsetters, its only inputs.LocalWalSyncImpl:_liveProofPendingWalIdsis empty.These are loop guards only: no change to which rows are written, retained or counted.
Measurements
Benchmark: 89k synced + 3.6k pending rows, real
LocalWalSyncImplwith the delta index, flutter test debug JIT on a host at load average ~300. Absolute numbers are inflated; compare the ratios.WalDerivedViewsconstruction, 92.6k rows (once per session)Tests
test/unit/wal_derived_views_sync_test.dart:rowsForIdsresult is compared against a freshWalDerivedViewsover the same list.bash test.sh test/perf/production_shell_gate_test.dart test/perf/global_sync_inventory_test.dart test/unit/wal_derived_views_sync_test.dartpasses.Not in this PR (measured, disclosed)
WalIndexWorkerindex saves still take seconds per added row on a 92k index. They run off the UI isolate but compete for background CPU.SyncDetailsSheet(SyncPipelineAmounts.of(allWals))displaySortedWalsre-sort after a membership changeopenOfflineSyncDetailstwin set, built per tapautoRemoveSyncedCopiespinned off by migration, andsyncedAt == 0rows are never swept. That is how phones reach ~100k rows. This is a product decision and is not changed here.WalDerivedViewsconstructor /pendingWork), which changes the same file without semantic overlap. Whichever lands second rebases.Product invariants affected
Failure-Class: none
UI-Evidence: none
🤖 Generated with Claude Code