Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf: desktop and server start without shell and fork waits, and thread views stay mounted #18219

Closedmaria-rckswants to merge 250+ commits intot3/app-startup-performance-audit fromt3/perf-wave2opened View on GitHub

maria-rckscommented

stacked on #17609. this diff shows only this layer.

trimmed client switching threads, typing into the destination composer and opening the terminal

linux child processes start from a small spawn host, provider adapters load on first use, and thread lists read a compact projection. desktop starts its backend and window before waiting for the login shell. the client retains and recycles recent thread views, isolates their popups, virtualizes pull request lists, and overlaps connection reads with authentication.

migration 64 rebuilds derived thread read rows from canonical data, upgrades databases from earlier builds that used 62 or 63, and repairs the sweep indexes those builds skipped.

historical measurements of the retained spawn-host path, medians of five interleaved linux runs: a 320-process vcs sweep fell from 5,733 to 2,397 ms, and settings rpc p50 during the sweep fell from 494 to 10.2 ms. these measure that path before trimming, not the final layer's total startup gain.

model: claude-opus-5-5 coordinating gpt-6.1-sol subagents, harness: claude code in t3 code.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. juliusmarminge added labelsmacroscope-review

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Macroscope has since reviewed this pull request. An earlier review was skipped by a cost limit; a review has now completed, so that notice no longer applies.

    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs Human Approval

      Macroscope's review found this PR requires human approval — This XXL PR introduces broad production behavior changes across desktop startup, Linux process management, server persistence/protocols, and retained web UI views, including new infrastructure and migrations. It also adds static-analysis suppression directives and changes default runtime behavior, so the scope and omitted files require human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire—4.9 KiB—6.8 KiB✅
      CodexThread snapshot wire—3.8 KiB—4.9 KiB✅
      CodexLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
      CodexLive turn WebSocket decoded—20.8 KiB—29.3 KiB✅
      CodexLive turn messages—1—8✅
      ClaudeTotal thread wire—5.0 KiB—6.8 KiB✅
      ClaudeThread snapshot wire—3.8 KiB—4.9 KiB✅
      ClaudeLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
      ClaudeLive turn WebSocket decoded—21.2 KiB—29.3 KiB✅
      ClaudeLive turn messages—2—8✅

      Baseline: unavailable · PR result: 7b308e0 · 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: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

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

    6. Independent measurements for why the spawn host helps, with the cause and numbers from a real install.

      Cause. On Linux, Node starts each child with a plain fork (clone(... SIGCHLD) in strace, no shared memory). The spawn() call blocks the main thread while the kernel copies the parent's page tables, and that time grows with the server's resident memory. I timed 300 git --version spawns from a Node 26.12 process holding ballast. The call took 0.79 ms at 87 MB resident and 5.5 ms at 790 MB. It took 13 ms at 1.7 GB and 22.7 ms at 2.1 GB (WSL2, one host, load about 5).

      A real-size server. Upstream fcda161afb, a copy of a 15 GB database (2,053 threads), auto-settle off, run from source. In the 10 s after the server answered its first request, the main thread was busy for 9.8 s, and 7.7 s of that was spawn itself. About 1,460 git processes came from ThreadPullRequestServiceV2.synchronize, roughly 5.4 ms each, which matches the 790 MB figure above. A trivial HTTP request in that window waited a median of 86 to 95 ms (maximum 144) against 3 ms on an empty database (3 boots against 2).

      A long-running install. The live server on this machine holds 1.4 to 1.6 GB resident (peak 2.76 GB). Its trace over the last 29 minutes has 16,063 process spawns, 558 a minute, and 10,634 of the 13,709 git commands sit under the pull-request sync. At about 13 ms a spawn that would be roughly 7 s of every minute. Two caveats. The 13 ms is interpolated from the ballast test, not measured on that process. The average over the previous 314 minutes was 64 spawns a minute, so this window is a busy one.

      Not covered: bare-metal Linux (all numbers are WSL2) and macOS (libuv uses posix_spawn there). I did not run the spawn host in this PR; these are the baseline numbers for the cost it removes.

      Measured by claude-sonnet-5-5 via Claude Code in T3 Code, on behalf of bompus.

    7. Note

      Written by claude-opus-5-5 on behalf of Maria

      thanks, these line up with what the spawn host was built for. fork blocking the main thread while page tables copy, scaling with resident memory, is the cost it moves off the server. our own numbers on linux bare metal: a 320-process vcs sweep went 5,733 → 2,397 ms and settings rpc p50 during the sweep 494 → 10.2 ms. your 15 gb / 2,053-thread trace (7.7 s of spawn in 10 s, ~1,460 git calls from pull request sync) is a larger and more realistic case than ours. macos isn't affected the same way since libuv uses posix_spawn there, and the host only runs on linux.

    8. juliusmarminge assignedjuliusmarminge

    9. Taking over the responsibility assessment for batch sidebar-threads-20. The diff is available now; I am checking the actual parent stack and which claims can be verified from this headless Linux VM before deciding whether a focused rebuild is responsible. I will not push an unmeasured desktop startup rewrite or merge this PR.

    10. Batch sidebar-threads-20 responsibility assessment: blocked for publication as scoped; unchanged and unmerged. Thanks @maria-rcks for the measured performance work, and @bompus for the independent fork-cost investigation.

      The diff is available now: head 4f439e9, actual base 488b121 on the still-open parent #17609. I assessed the 225-file layer against its actual base and current main using its diff inventory, all 247 commits' metadata, source traces, review comments, current-head CI and independent reviewers. No code was changed or pushed; no replacement PR was opened.

      Confirmed blockers:

      • Backup preparation opens a WAL reader before rm/mkdir, outside cleanup coverage. A fresh disposable reproduction imported byte-identical head source and independently confirmed both rm/ENOTDIR and mkdir/EACCES: WAL truncation reports busy=0 before invocation, busy=1 after rejection while the reader process remains alive, and busy=0 after it exits. Cover staging-directory setup with the reader cleanup and prove both failure paths.
      • Retained-terminal setup does not restore visibility after cleanup clears it when the session key changes while visible remains true. This is source-reviewed, not visually reproduced here.
      • The branch uses migration IDs 63/64 for sweep indexes and compact reads; current main uses them for dropping unused V1 projections and canonicalizing PR links. A main-based rebuild needs a fresh migration/upgrade design, including databases that ran earlier preview histories.
      • Desktop startup has real dependencies on the parent's window/authentication readiness behavior. The shell wait also gates spawn, IPC, secret storage, updater and shutdown paths. This headless VM cannot establish packaged Electron correctness or startup gains.

      A further Linux desktop risk needs confirmation: removing the post-shell password-store selection and gating secret storage only on a missing DBus address may change credential access when session variables are supplied or corrected by the shell. This is a source-traced concern, not a reproduced regression. Verify the selected backend and decryption of saved credentials under those session conditions.

      The held-typing and cached-primary retention findings have source fixes at this head. The spawn-output finding remains disputed; no contrary runtime reproduction is claimed. Current-head passing CI does not resolve the confirmed defects or supply desktop measurements. The body's Linux figures explicitly describe a historical pre-trim path; the independent WSL figures measured baseline fork cost without running this head.

      Tests before → after: unchanged; no tests added or removed. On unchanged main, DesktopShellEnvironment.test.ts passed 22 tests and processRunner.test.ts passed 15 (37 total). DesktopBackendManager.test.ts and DesktopBackendPool.test.ts could not collect: Electron's automatic download failed with TypeError: fetch failed, then Electron failed to install correctly. Desktop/server typecheck and targeted lint passed. No live web/server flow, packaged Electron launch, screenshots, or performance benchmark was completed. macOS, Windows, iOS and Android were not verified.

      To resume the full desktop scope: resolve the parent integration, fix the confirmed defects and migration histories, then build matched packaged baseline/candidate versions on graphical Linux, macOS and Windows. Use identical disposable fixture homes and normal desktop launch entry points. Measure cold and warm launches separately, with ordinary shell startup and a controlled five-second profile delay, for at least ten interleaved launches per build. Record process start, first visible window, backend readiness, first usable composer and first successful provider command; report individual timings plus median/p95 with traces or video. Verify failed shell probes, quit during hydration, early authentication, and hydrated environment propagation (PATH, locale, SSH socket and CA settings).

      A Linux-only spawn-host concern is technically separable and does not inherently require the parent. Its Effect spawner patch is also a candidate for an upstream proposal; no upstream change was made. It would drop the desktop reordering, retained views, compact projections, lazy providers and connection overlap, so it is not a verified substitute for this PR's full claim. Any such main-based rebuild needs its own stdio/error/cancellation/host-failure checks, packaged Linux proof, and fresh interleaved workload/RPC-latency/memory measurements; the historical figures cannot be reused as proof.

      Fresh tests/reproduction assessment: Codex GPT-6 Astra high. Independent implementation assessment: Codex GPT-6.1 Sol high. One read-only adversarial review round: Claude Opus 5.5 and Codex GPT-6 Sol. Coverage centered on dependency, migration, process, terminal and authentication risks; this is not a clean correctness audit of every retained-web-view change. Outstanding maintainer approval remains required for the resulting production scope.

      Maintainer assessment: GPT-6.1 Sol high, Codex harness in T3 Code. This original remains open.

    11. Note

      Written by claude-opus-5-5 on behalf of Maria

      thanks for the assessment. the confirmed defects are fixed at 462c56da12, which also merges current main through #17609.

      96c8ef6075 puts backup staging setup (rm/mkdir) inside the reader cleanup. the extended serviceLauncher test covers rm ENOTDIR and mkdir EACCES; both failed before and now leave the wal checkpoint at busy=0. 462c56da12 restores retained-terminal visibility when the session key changes while the drawer stays visible; its regression failed before, and a seeded browser run switched threads with the drawer open, rendered both terminals and accepted input. 9ede4daf1b restores linux password-store selection after shell hydration while the window still opens first; electron under xvfb picked gnome_libsecret on base and fixed with a missing or stale parent dbus address, saved credentials survived relaunch and base-to-fixed reads, and the reverse xdg case matches base.

      migrations now sit after main's 063/064: #17609 adds 065 and this layer 066, and databases that ran earlier preview histories (our 63/64) apply main's 063/064 effects idempotently; fresh and published-head upgrades were verified at runtime. still open: packaged desktop timing on graphical linux, macos and windows, which this headless linux machine can't produce.

      terminal stays visible and accepts input after switching threads with the drawer open

    12. maria-rcks closed this

Sign in to join this conversation.