perf(desktop): speed up cold Linux x64 backend startup#32987
Problem
Release bytecode preparation loaded the CLI but missed the server graph it imports dynamically. Linux packages skipped preparation entirely, so cold desktop backends compiled those startup modules again.
Change
Prepare the CLI and server declarations with packaged Electron, require both cached entries, and enable generation for native Linux x64. Keep Linux arm64 skipped. Reclaim recognized AppImage caches after their mounts disappear while preserving live, concurrent, and unfamiliar directories. Runtime cache identity, source fallback, signed resources, and AppImage main-process caching retain their existing behavior.
Scope and approval
This is a focused repair of the existing prepared-bytecode capability and completes its documented Linux packaging/relocation validation gate. The cleanup is needed for the per-mount cache path this enables. No new UI, configuration, or workflow is introduced. Requested scope.
Verification depth is standard because generated bytecode and per-mount cache lifetime cross native boundaries.
Verification
Command readiness improved; window and usable-composer timing remain inconclusive.
Current-main versus final packaged build
Ubuntu 24.04 x64 Boat VM, 4 vCPU / 8 GB, unsigned Linux directory packages. Same Electron 44.10.1 / embedded Node 24.22.1, packaging Node 26.12.1 / pnpm 12.14.0. Fixed 12-project / 48-stopped-thread synthetic fixture; warm OS pages and cold runtime code cache on every launch. Two warmup pairs, then 20 alternating AB/BA pairs, all 40 measured launches retained.
Baseline: ade473018d32003658b7d38693e083ee2e314bd8.
Candidate: 37aa1e1fedfe794155571d498f30cc894e5b91d1.
| Milestone | Baseline median / p95 | Candidate median / p95 | Paired median delta, 95% interval |
|---|---|---|---|
| Visible native window | 617 / 791 ms | 653 / 852 ms | +15 ms [−29, +75], inconclusive |
| Command ready | 1,518 / 1,799 ms | 1,361 / 1,684 ms | −141 ms [−247, −83] |
| Composer probe | 2,496 / 2,829 ms | 2,352 / 2,845 ms | −78 ms [−217, +83], inconclusive |
Command-ready is a successful descriptor response behind the server's command-readiness gate, not an open socket. The composer probe asserts editable input; its attempted .fill('') is not clearing proof. A separate integrated run verified thread navigation, keyboard input and clearing, and normal Electron quit on the exact final artifact (screenshot).
Raw paired timings, statistics, build commands, hashes, and methodology. Complete proof report. p95 uses nearest rank; intervals use 20,000 paired bootstrap resamples. Earlier CLI-prepared/full-prepared proxy and 6417151c09 results are historical, not this comparison.
| 1 | # Build each exact source tree with its own COMMIT and a separate OUTPUT. |
| 2 | pnpm install --frozen-lockfile |
| 3 | T3CODE_COMMIT_HASH="$COMMIT" node scripts/build-desktop-artifact.ts \ |
| 4 | --platform linux --target dir --arch x64 --output-dir "$OUTPUT" --verbose |
| 5 | |
| 6 | # Serialized paired driver; the methodology defines the isolated fixture and flags. |
| 7 | xvfb-run -a -s '-screen 0 1280x900x24 -noreset' python3 "$PAIRS" \ |
| 8 | --node "$NODE26" --harness "$HARNESS" --source "$CONTROLLER_SOURCE" \ |
| 9 | --base "$BASE_BINARY" --head "$HEAD_BINARY" --output "$NEW_OUTPUT" \ |
| 10 | --fixture returning --returning-home "$FROZEN_COLD_FIXTURE" --rounds 20 |
pnpm exec vp run check:changedpassed format, lint, knip, affected typechecks, and 11 tests. Nine focused cache cases passed; isolated mutation probes failed for omitted server preparation, ambiguity validation, reclamation, and platform guards, then passed after restoration.- Production directory and AppImage builds passed. Actual read-only FUSE mounts accepted server/runtime bytecode after relocation. A captured crash left a stale cache; a later launch reclaimed it while preserving a concurrent live cache. Normal quits cleaned each current directory. Package and original fixture hashes stayed unchanged.
- Normally warmed per-build fixtures restored accepted main caches. Three warm-control pairs are descriptive only. No warm-cache, AppImage timing, onboarding, native macOS/Windows/arm64 timing or purity, combined-ticket, window, or usable-composer gain is claimed.
- Cleanup deliberately preserves directories with no recognizable stale links or extant mounts. Chunk ambiguity fails the build instead of importing an unrelated entry. These are accepted P3 limits from local cubic, not open correctness findings.
Independent proof audit passed with no remaining code-proof gaps, including real permission-error continuation and malformed-cache preservation probes.
Council review
| Reviewer | Round 1 | Round 2 | Round 3 |
|---|---|---|---|
| GPT 6.1 Sol | 9/10 | 9/10 | 9/10 |
| Claude Opus 5.5 | 8/10 | 9/10 | 9/10 |
| Grok 4.7 | 9/10 | 9/10 | 9/10 |
Round-one ambiguity and crash-cleanup findings were fixed. The remaining round-two arm64 release concern was resolved by retaining the previous Linux arm64 skip. Final council has no open blocker or should-fix item. Local cubic has no P0/P1 findings; its two P3 limits are described above.
Built and reviewed with GPT 6.1 Sol, Claude Opus 5.5, and Grok 4.7 in T3 Code, using the Codex, Claude Agent SDK, and Grok harnesses.
Checks
Added 4 commits
Approvability
Verdict: Approved at 37aa1e1
Macroscope's review found this PR approvable — This extends prepared backend bytecode to native Linux x64 packages and cleans up abandoned AppImage caches. The effects are limited to regenerable compilation artifacts, with runtime validation and constrained cleanup.
You can add or adjust custom eligibility rules. Learn more.
No actionable comments were generated in the recent review.
Walkthrough
-
Prepared bytecode generation now supports native Linux x64 builds. Generation imports and verifies both the bundled CLI and server modules. AppImage launches can remove qualifying cache directories whose linked mounts no longer exist.
Changes: Prepared server bytecode
Layer / File(s) Summary Linux x64 packaging scope
scripts/prepare-server-compile-cache.cjs,scripts/lib/server-compile-cache.test.ts,docs/operations/development.mdThe packaging hook enables Linux x64 and skips other Linux architectures. Tests cover supported and skipped targets. Documentation describes Linux builds and AppImage cache handling. Generate and verify both module caches
scripts/lib/server-compile-cache.ts,scripts/lib/server-compile-cache.test.ts,docs/operations/development.mdGeneration requires exactly one bundled server entry, imports it with the CLI, and verifies both modules appear in the cache. Tests cover ambiguity, generated entries, and cache consumption. The packaged-engine format check now requires both entries. Clean stale AppImage cache directories
scripts/lib/server-compile-cache.ts,scripts/lib/server-compile-cache.test.tsAppImage launches remove qualifying cache directories only when a symbolic link points to a missing mount. Tests check stale and non-stale directory cases. Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Sequence Diagram(s)
mermaid1 sequenceDiagram 2 participant PackagingHook as prepare-server-compile-cache.cjs 3 participant Generator as generatePreparedServerCache 4 participant CLI as bundled CLI module 5 participant Server as bundled server module 6 participant CompileCache as compile cache 7 PackagingHook->>Generator: generate prepared cache 8 Generator->>CLI: import CLI module 9 Generator->>Server: import server module 10 Generator->>CompileCache: flush and verify module entries Possibly related PRs
- pingdotgg/t3code#28700: Changes the same Linux target gate, but skips Linux rather than enabling x64 generation.
- pingdotgg/t3code#29251: Also enables Linux bytecode generation and updates the development guide.
- pingdotgg/t3code#28572: Introduces the prepared server bytecode functions and packaging hook modified here.
Suggested reviewers:
yash-singh1,macroscopeapp
Merge Risk: External image Minimal · up to 37aa1
-
No merge-blocking issue was identified in the prepared-bytecode changes; normal build and release checks can proceed.
Pre-merge checks: Passed 4
-
Check name Status Explanation Title check Passed The title "perf(desktop): speed up cold Linux x64 backend startup" matches the main change. The PR prepares the CLI and server bytecode, enables generation for native Linux x64, and reports a paired m… Description check Passed The description follows the repository template. It has Problem, Change, Scope and approval, and Verification sections. The Problem section states the failure and its effect on cold Linux backends. Th… Linked Issues check Passed Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request. Full details: Title check
-
Explanation
The title "perf(desktop): speed up cold Linux x64 backend startup" matches the main change. The PR prepares the CLI and server bytecode, enables generation for native Linux x64, and reports a paired median reduction of about 141 ms in command-ready time on a cold Linux x64 packaged backend. The title is conventional, specific, and does not list files. It does not mention the AppImage cache cleanup, which is a secondary part of the change. The title is also accurate about the reported gain, since the description treats command readiness as the only measured improvement with a conclusive interval.
Full details: Description check
-
Explanation
The description follows the repository template. It has Problem, Change, Scope and approval, and Verification sections. The Problem section states the failure and its effect on cold Linux backends. The Change section names the affected components and what stays the same. Scope and approval explains why this is a focused repair of an existing capability and links a requested-scope document, but it does not link a triaged issue or a maintainer approval comment, which the template asks for on a non-trivial change. The Verification section gives detailed commands, timings, fixture details, mutation probes, and limits. It also reports council reviews and a proof audit. The template's opening comment asks for a conventional commit title, and the title meets that requirement. The main gap is the missing triaged issue or maintainer approval link in the scope section. The author also links external sites (postplan.dev, a gist, and an image host). Those links are not verifiable from the PR text alone, so the reviewer should confirm that they resolve and that they are accessible to the team.
Resolution
Consider adding a link to the triaged issue or the maintainer discussion that approved this scope. The current scope section relies on an external 'requested scope' link, which reviewers cannot verify from the repository. Confirm that the external links (requested scope, proof report, raw timings, and screenshots) resolve and are accessible to reviewers.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
External image Recent review info
-
External image Run configuration
-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: ade4730
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
369eb7a7-c786-433d-bb07-6f5f00ae84ca
External image Commits
-
Reviewing files that changed from the base of the PR and between ade473018d32003658b7d38693e083ee2e314bd8 and 37aa1e1fedfe794155571d498f30cc894e5b91d1.
External image Files selected for processing: 4
-
docs/operations/development.mdscripts/lib/server-compile-cache.test.tsscripts/lib/server-compile-cache.tsscripts/prepare-server-compile-cache.cjs
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
External image Recent review info
-
External image Run configuration
-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: ade4730
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
369eb7a7-c786-433d-bb07-6f5f00ae84ca
External image Commits
-
Reviewing files that changed from the base of the PR and between ade473018d32003658b7d38693e083ee2e314bd8 and 37aa1e1fedfe794155571d498f30cc894e5b91d1.
External image Files selected for processing: 4
-
docs/operations/development.mdscripts/lib/server-compile-cache.test.tsscripts/lib/server-compile-cache.tsscripts/prepare-server-compile-cache.cjs
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-