Skip to content

perf(mobile): bound the parsed review cache - #9749

Merged
t3dotgg merged 1 commit into
mainfrom
t3code/perf-mobile-review-cache
Sep 4, 2026
Merged

perf(mobile): bound the parsed review cache#9749
t3dotgg merged 1 commit into
mainfrom
t3code/perf-mobile-review-cache

Conversation

@t3dotgg

@t3dotgg t3dotgg commented Sep 4, 2026

Copy link
Copy Markdown
Member

Mobile review keeps every parsed diff and its native rows until the app registry resets. Opening more sections keeps adding memory.

The cache now keeps up to eight entries and 4,194,304 source characters. Nearby prewarming uses the same budget and reserves room for the selected section. Oversized diffs are not cached or prewarmed. Current view references and row IDs stay valid.

In a Node source proof with 64 sections, retained parsed diffs and prepared native row sets each fall from 64 to 8. The retained heap delta falls from 47.9 MB to 10.7 MB. In the 10-section prewarming proof, switching between the first two sections adds no parses after warmup. These are not device measurements.

M6 in the performance audit remains partial. Raw patches, drafts, comments, and preferences are unchanged. The source-character limit is not an exact heap-byte limit.

Verified with 31 focused tests, mobile typecheck, targeted lint, and real-source GC and prewarming proofs. No native code changed. No browser, device, or native build verification ran.

Created with GPT-6 Astra (preview) in Codex.


Note

Medium Risk
Changes review diff caching and idle prewarming semantics; wrong eviction or budget accounting could cause extra parses or stale assumptions, but behavior is heavily tested and scoped to mobile review performance.

Overview
Bounds mobile review parsed-diff memory by replacing unbounded per-section atom caches with a single LRU store capped at 8 sections and 4 MiB of raw diff source (not parsed/native heap).

getCachedReviewParsedDiff now tracks source length, evicts oldest entries when limits are hit, skips caching oversized patches (still returns a fresh parse), and clears on appAtomRegistry.reset. Whitespace-trimmed hits refresh LRU order; content changes reclaim budget for that section.

Prewarming no longer warms every other loaded section. getReviewDiffPrewarmSections picks nearest neighbors that fit the shared entry and character budget (reserving the selected section, including when cached source was retained with trailing whitespace). prewarmReviewDiffSection bails on null or oversized diffs without parsing.

New unit tests cover LRU across threads, source-budget eviction/reclaim, oversized behavior, registry reset, and prewarm selection/reuse.

Reviewed by Cursor Bugbot for commit 0369853. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Bound parsed review diff cache to 8 entries and 4 MiB source budget

  • Replaces the per-section atom-family cache with a single registry-owned LRU map in reviewState.ts, enforcing an 8-entry maximum and a 4 MiB aggregate source-character limit across all threads
  • Adds getReviewParsedDiffSourceCharacterCount so prewarming callers account for the full retained source length, including whitespace absent from an equivalent normalized input
  • Reworks useReviewDiffPrewarming to plan prewarming of at most 7 loaded neighboring sections ordered by distance from the selection, skipping neighbors that exceed the remaining source budget
  • Direct prewarming now returns early for oversized sources without invoking parsed-diff construction
  • Risk: getCachedReviewParsedDiff evicts oldest entries globally across thread keys when either the entry count or source budget is exceeded; callers expecting unbounded retention will see parsed results rebuilt on cache misses

Macroscope summarized 0369853.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 13.5 KiB 13.7 KiB +240 B (+1.7%) 15.1 KiB
Codex Thread snapshot wire 7.0 KiB 7.0 KiB +7 B (+0.1%) 7.3 KiB
Codex Live turn WebSocket wire 6.5 KiB 6.7 KiB +233 B (+3.5%) 7.8 KiB
Codex Live turn WebSocket decoded 57.0 KiB 58.5 KiB +1.5 KiB (+2.6%) 66.4 KiB
Codex Live turn messages 8 10 +2 (+25.0%) 21
Claude Total thread wire 13.7 KiB 13.8 KiB +16 B (+0.1%) 15.1 KiB
Claude Thread snapshot wire 7.0 KiB 7.0 KiB +3 B (+0.0%) 7.3 KiB
Claude Live turn WebSocket wire 6.7 KiB 6.7 KiB +13 B (+0.2%) 7.8 KiB
Claude Live turn WebSocket decoded 59.3 KiB 59.3 KiB 0 B (0.0%) 66.4 KiB
Claude Live turn messages 10 10 0 (0.0%) 21

Baseline: c8f77e0 · PR result: 0369853 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 113.8 KiB
  • Claude decoded thread snapshot: 114.5 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@macroscopeapp

macroscopeapp Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 0369853

Macroscope's review found this PR approvable — This is a contained mobile performance change that bounds parsed review-diff retention and optional prewarming without changing the rendered review results or introducing a new capability. Focused tests cover LRU eviction, source budgets, reset behavior, and reuse of parsed/native results.

You can add or adjust custom eligibility rules. Learn more.

@t3dotgg
t3dotgg merged commit d6e29dc into main Sep 4, 2026
23 checks passed
@t3dotgg
t3dotgg deleted the t3code/perf-mobile-review-cache branch September 4, 2026 18:38
@t3dotgg t3dotgg mentioned this pull request Sep 4, 2026
66 tasks
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Sep 4, 2026
## What's Changed
* perf(server): use one query for buffered provider events by @t3dotgg in pingdotgg/t3code#9706
* perf(relay): avoid repeated activity decoding by @t3dotgg in pingdotgg/t3code#9708
* perf(web): stop continuous chat status animations by @t3dotgg in pingdotgg/t3code#9709
* fix(mobile): preserve saved work after storage read failures by @t3dotgg in pingdotgg/t3code#9710
* perf(web): stop replaying terminal buffers on rollover by @t3dotgg in pingdotgg/t3code#9707
* feat(web): preview pull request links by @maria-rcks in pingdotgg/t3code#9631
* perf(client): reduce thread-list update work by @t3dotgg in pingdotgg/t3code#9716
* fix(server): settle inactive threads with open PRs by @Gigioxx in pingdotgg/t3code#9610
* fix(server): bound slow-client event buffers by @t3dotgg in pingdotgg/t3code#9715
* test(server): allow either valid file-search match by @t3dotgg in pingdotgg/t3code#9720
* fix(web): match provider settings layout for disconnected devices by @flamboh in pingdotgg/t3code#9619
* fix(web): keep the slash menu above the composer when vertical space is short by @Mnigos in pingdotgg/t3code#9625
* fix(mobile): remove provider setup by @juliusmarminge in pingdotgg/t3code#9721
* perf(web): stop rendering hidden terminals by @t3dotgg in pingdotgg/t3code#9718
* fix(mobile): read file-backed image drafts before enabling them by @t3dotgg in pingdotgg/t3code#9713
* perf(server): replay only the selected thread by @t3dotgg in pingdotgg/t3code#9726
* fix(web): mute composer helper text by @jakeleventhal in pingdotgg/t3code#9654
* feat(web): unpin threads from the sidebar multi-select menu by @gsimone in pingdotgg/t3code#9651
* perf(web): reuse timeline rows while text streams by @t3dotgg in pingdotgg/t3code#9725
* fix(relay): bound stalled push requests by @t3dotgg in pingdotgg/t3code#9734
* perf(server): stop caching unused OpenCode tool parts by @t3dotgg in pingdotgg/t3code#9738
* fix(web): fold single trailing activity by @maria-rcks in pingdotgg/t3code#9739
* fix(web): show project settings for new threads by @maria-rcks in pingdotgg/t3code#9743
* perf(mobile): bound the parsed review cache by @t3dotgg in pingdotgg/t3code#9749


**Full Changelog**: pingdotgg/t3code@v0.0.39-nightly.20260904.1279...v0.0.39-nightly.20260904.1280

Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.39-nightly.20260904.1280
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant