Skip to content

perf(mobile): batch large replays and prefetch history responsively - #579

Merged
huichen merged 3 commits into
mainfrom
claude/mobile-large-replay
Sep 12, 2026
Merged

huichen merged 3 commits into
mainfrom
claude/mobile-large-replay

Conversation

@huichen

@huichen huichen commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fold large Mobile replays with one owned dedup set and deferred run snapshots rather than copying/rebuilding on every event.
  • Add arrival-ordered append/snapshot/fork to the shared projector without changing existing ingest semantics; isolate mutable accumulators for cancellable replay.
  • Yield between bounded work slices and commit the completed timeline/cursor together. Preserve projection accumulators for subsequent live tail events.
  • Remove the fixed 1.5s paging cooldown, retain commit/native-layout/100ms quiet barriers, and prefetch at most one page per deliberate gesture within a capped viewport look-ahead.
  • Avoid rebuilding the full paging ID index on idle streaming text updates.

Validation

  • Mobile typecheck + ESLint; 53 suites / 752 tests passed after main sync.
  • Desktop typecheck + ESLint + Stylelint; 109 files / 959 tests passed. Shared thread-projection typecheck passed.
  • Android and iOS production Hermes exports passed.
  • 10k / 50k / 100k text events: one final display snapshot, exact content/tokens, independent tasks run before completion.
  • Parity cases cover 300 interleaved tools, thinking, usage, compaction, approvals, errors, truncation, duplicates/out-of-order events; cancellation and restart preserve committed projector/cursor state.
  • Paging tests cover bounded prefetch, no programmatic/momentum cascades, native layout barriers and idle index work.

A recorded 5,002-event host comparison: 5,002 snapshots / 210 ms single-event versus one snapshot / 15 ms synchronous batching or 136 ms cooperative batching including timer scheduling. Timings are not phone FPS/latency promises; deterministic correctness/work assertions are the gates.

Initial forking, single large payloads and final snapshot construction remain non-preemptible. Network replay fetching/retention, data-source paging and giant-message block virtualization are unchanged. Details: docs/mobile-latency-diagnosis.md.

@huichen
huichen enabled auto-merge (squash) September 12, 2026 16:31
@huichen
huichen merged commit 9733fbc into main Sep 12, 2026
12 checks passed
@huichen
huichen deleted the claude/mobile-large-replay branch September 12, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant