Repository navigation
perf(ios): stop per-frame full-buffer copies on the main actor - #279
Merged
Merged
Conversation
Problem: Three buffers did whole-buffer work on the main actor once they were full. - RemoteTerminalOutputStore rebuilt committed + pending and re-trimmed the 200 KB tail on every 16 ms flush, even while the rich renderer was on screen and nothing read the text. - DiagnosticsLog, at its 8000-entry cap, mapped every category, removed index 0 and forced a full JSONL rewrite for each new entry. Verbose logging is on by default, so this ran constantly. - The renderer engine kept each tab's replay buffer (up to 400 KB) after the playback was built from it, although nothing reads it again. - The diagnostics viewer filtered all entries twice per body. Decision: - The output store appends in place and trims only after 32 KB of slack. visibleOutput still returns exactly the retained cap. - DiagnosticsRetentionPolicy gains an entryTarget: over 8000 entries the log trims to 7000 in one batch, and removals happen in a single pass. - ensurePlayback frees the replay once the playback exists, and the diagnostics list filters once per body. Rationale: All three are amortisation changes with no visible behaviour change: the same tails are retained and displayed, and the costs move from every frame or record to once per batch. Validation: xcodebuild test, Chau7RemoteApp scheme, iPhone 17 Pro simulator: 129 tests, 0 failures. New tests cover the newest tail surviving amortised trims, batch trimming to the target, no trim at the cap, and a target above the cap failing closed. The replay release has no direct test, because the engine actor is not in the host-less test bundle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
schiste
marked this pull request as ready for review
October 23, 2026 15:43
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ance-main-thread-output-b # Conflicts: # CHANGELOG.md
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.
Summary
iOS app performance: main-thread output buffering, diagnostics log trimming, renderer leaks
Problem: Three buffers did whole-buffer work on the main actor once they were
full.
the 200 KB tail on every 16 ms flush, even while the rich renderer was
on screen and nothing read the text.
index 0 and forced a full JSONL rewrite for each new entry. Verbose
logging is on by default, so this ran constantly.
the playback was built from it, although nothing reads it again.
Decision: - The output store appends in place and trims only after 32 KB of
slack. visibleOutput still returns exactly the retained cap.
log trims to 7000 in one batch, and removals happen in a single pass.
diagnostics list filters once per body.
Rationale: All three are amortisation changes with no visible behaviour change:
the same tails are retained and displayed, and the costs move from every
frame or record to once per batch.
Changes
Checklist
pnpm quality:prepushpasses, orpnpm quality:prepush:fullfor high-impact changescargo test --workspacepasses inapps/chau7-next(if macOS app changes)swift test --package-path apps/chau7-ios/Chau7Corepasses (if Swift changes)Test plan
xcodebuild test, Chau7RemoteApp scheme, iPhone 17 Pro simulator: 129
tests, 0 failures. New tests cover the newest tail surviving amortised
trims, batch trimming to the target, no trim at the cap, and a target
above the cap failing closed. The replay release has no direct test,
because the engine actor is not in the host-less test bundle.
Commits:
Opened by aethyme broker push as a draft.