perf(desktop): speed up cold Linux x64 backend startup#32987

merged4
main
GitHub fork: t3/desktop-boot
opened17h agobyWWout Stiens
View on GitHubTwo-way sync enabledPR last imported 12h ago

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.

MilestoneBaseline median / p95Candidate median / p95Paired median delta, 95% interval
Visible native window617 / 791 ms653 / 852 ms+15 ms [−29, +75], inconclusive
Command ready1,518 / 1,799 ms1,361 / 1,684 ms−141 ms [−247, −83]
Composer probe2,496 / 2,829 ms2,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.

sh
1# Build each exact source tree with its own COMMIT and a separate OUTPUT.
2pnpm install --frozen-lockfile
3T3CODE_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.
7xvfb-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:changed passed 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

ReviewerRound 1Round 2Round 3
GPT 6.1 Sol9/109/109/10
Claude Opus 5.58/109/109/10
Grok 4.79/109/109/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

25 successful · 11 skipped
All checks passed
37aa1e1

Added 4 commits

  • perf(desktop): prepare server startup bytecode on Linux002fba7
  • fix(desktop): reclaim abandoned AppImage server caches0fa0afb
  • fix(desktop): limit Linux bytecode generation to x6437aa1e1
  • test(desktop): simplify prepared cache hook testsaa6020e
Synced from GitHub

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.

Synced from GitHub

Explain Change →

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.md
The 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.md
Generation 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.ts
AppImage 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)

mermaid
1sequenceDiagram
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

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 nameStatusExplanation
Title checkPassedThe 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 checkPassedThe 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 checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck 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

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.md
  • scripts/lib/server-compile-cache.test.ts
  • scripts/lib/server-compile-cache.ts
  • scripts/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.