Skip to content

perf: checkpoint startup boundaries and bundle diagnostics - #11539

Closed
nwparker wants to merge 20 commits into
mainfrom
nwparker/big-picture-perf
Closed

nwparker wants to merge 20 commits into
mainfrom
nwparker/big-picture-perf

Conversation

@nwparker

@nwparker nwparker commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Draft status

This is an in-progress stacked checkpoint for the performance architecture work. It is intentionally a draft and is not merge-ready yet; the larger architecture objective and cross-platform packaged validation are still ongoing.

Architecture and retained tranches

  • Add deterministic Electron entry manifests, gzip/raw budgets, CI ratchets, and static-closure validation.
  • Add Phase 0 startup clocks, subprocess/RPC diagnostics, main-thread evidence, and mobile WebView/process-memory diagnostics.
  • Repair SFTP download/upload false boundaries while preserving runtime, SSH, WSL, relay, abort, and folder-workspace ownership.
  • Split the Electron main composition root into measured app-ready capability/owner boundaries with exact identity, ordering, and teardown contracts.
  • Move measured renderer leaves behind lazy boundaries: Linear setup, dashboard terminal preview, skill-update dialog, pinned-tab close dialog, and terminal view attributes.
  • Begin host-owned repository intelligence with a live, versioned Git repository snapshot owner for native, exact-distro WSL, and each SSH provider instance.
  • Migrate automatic Checks to consume complete fresh snapshots and subscribe to exact host-owned generation/revision events without another polling loop.
  • Retain negative audits where a split was not safe or did not meet strict allocation criteria, including main i18n, synthetic-title behavior, the popout root-store closure, Markdown template picker, recent-tab switcher, and the combined app-overlay allocation experiment.

The architectural review and per-tranche A/B reports are under docs/readme/ and tools/benchmarks/results/.

Measured startup graph

Entry Review baseline Current exact-tree output Change
Electron main raw 8,149,600 795,061 -7,354,539 (-90.2%)
Electron main gzip 1,701,691 177,873 -1,523,818 (-89.5%)
Preload raw 130,769 131,910 +1,141 (+0.9%)
Main renderer raw 11,104,115 8,416,672 -2,687,445 (-24.2%)
Dashboard popout raw 5,893,311 4,507,253 -1,386,058 (-23.5%)
Web renderer raw 4,361,095 4,360,948 -147

Current renderer reachability is 292 JS / 2 CSS for the main window, 77 / 2 for popout, and 33 / 1 for web. Current budget headroom is 30,048 raw bytes for Electron main, 90 for preload, 49,742 for the main renderer, 30,695 for popout, and 23,928 for web.

Latest allocation audits

  • Markdown template picker alone reduced main renderer raw by 1,144 bytes, but added 463 bytes and one JS file to popout and 424 bytes and one JS file to web.
  • Recent-tab switcher alone reduced main renderer raw by 455 bytes, but added 796 bytes and one JS file to popout and 390 bytes and one JS file to web.
  • Grouping both surfaces behind one deferred app-overlay module reduced main renderer raw by 3,745 bytes, but still added 463 bytes and one JS file to popout and 424 bytes and one JS file to web.
  • One narrowly scoped advancedChunks arm reduced main renderer raw by 6,050 bytes, but recursively captured an 847,208-byte capability into every renderer entry, increasing popout by 25,372 bytes and web by 94,638 bytes.

All three experiments were rejected and restored file-for-file to the accepted build. Their durable reports preserve exact manifests, hashes, closure paths, behavior gates, and limitations.

Repository intelligence

The host-owned repository seams share identical in-flight status and upstream-status reads across concurrent native, WSL, and per-connection SSH callers:

Scenario Before Current
Native/WSL: 10 callers without signals 1 physical status run 1
Native/WSL: 10 callers with distinct signals 10 physical status runs 1
SSH: 10 callers without signals 10 git.status RPCs 1
SSH: 10 callers with distinct signals 10 git.status RPCs 1
Native/WSL upstream: 10 callers 10 chains / 40 Git calls 1 chain / 4 calls
SSH upstream: 10 callers 10 git.upstreamStatus RPCs 1

Those live reads publish immutable, monotonically revisioned repository snapshots containing repository identity, status, upstream state, conflicts, a worktree-graph placeholder, and per-projection freshness. Retention is bounded to 64 repository scopes, four variants per projection, 1,000 entries and ignored paths, and 64 Ki code units.

Per-caller status cancellation remains isolated, the last live status lease owns underlying cancellation, mutation invalidation fences old generations and suppresses stale publication, provider replacement isolates relay incarnations, and settled status or upstream results are never returned from a cache. Exact Git 2.25-compatible commands and SSH RPC payloads are unchanged.

The publication audit measured approximately +0.7 µs / +1.6 KiB sampled allocation for an empty status result, +3.5 µs / +16 KiB for 100 entries, and +29 µs / +151 KiB for the 1,000-entry retention bound. Callers still receive the exact original mutable result; retained entries are separate frozen copies.

Automatic Checks queries the exact host-owned snapshot seam before falling back to its existing fresh status/upstream path: desktop IPC for locally owned worktrees and background git.repositorySnapshot RPC for active runtime-owned worktrees. It admits only complete, current-generation, exact-branch projections; stale, failed, truncated, branch-mismatched, ambiguous-upstream, unsupported-runtime, and manual-refresh cases still execute fresh work.

Settled active poll followed by automatic Checks Before Current
Native/WSL physical status loads 2 1
Native/WSL physical explicit-upstream loads 2 1
SSH git.status RPCs 2 1
SSH git.upstreamStatus RPCs 2 1

The desktop path retains sender-scoped host-to-renderer subscriptions for both normal and reuseLineStats identities. invalidated events advance mutation/provider fences without launching work; ready is emitted only after the requested status and configured or explicit upstream projection is admissible. Checks then performs a memory-only projection query and coalesces events around an in-flight read.

SSH provider incarnation rebinding fences late old-provider events. Explicit unsubscribe, sender destruction/reload, visibility or context change, connection replacement, and handler disposal release exact listeners. Active runtime environments now resolve the exact worktree selector, native versus exact WSL identity, current SSH-provider incarnation, status identity, and optional push target through a query-only background RPC. Runtime snapshot subscriptions are now retained for automatic runtime-routed SSH Checks, as described below. The first bounded mobile consumer is retained after that section.

The subscription tranche adds 5,192 raw / 1,010 gzip bytes to Electron main and 1,019 / 177 to preload versus the prior checkpoint. All renderer entry raw sizes and JS/CSS counts remain unchanged.

Independent review corrected ambiguous embedded-upstream admission, late cross-context read completion, renderer send-failure/SSH-rebind cleanup, partial subscription cleanup when a sibling registration remains pending, project-level Windows/WSL runtime rebinding, background RPC classification, and the web preload fallback contract.

The Delete Worktree dialog is the next bounded snapshot consumer. Its warning-only dirty probe queries the exact normal and reuseLineStats status identities, admits only complete fresh status/repository/conflict siblings with matching identities, and selects the newest status projection revision. Missing or stale upstream data is intentionally irrelevant; cold, stale, failed, truncated, mismatched, unsupported, and runtime-routed reads retain the fresh fallback, while main-side deletion keeps the authoritative preflight.

Settled active poll followed by Delete Worktree warning Before Current
Native physical status loads 2 1
Exact-distro WSL physical status loads 2 1
SSH git.status RPCs 2 1

The Delete Worktree tranche leaves Electron main and preload byte-identical. Renderer index changes by +63 raw / -67 gzip bytes with unchanged 292 JS / 2 CSS reachability; popout and web raw bytes and file counts are unchanged. The following runtime-query tranche leaves main, preload, index, and popout raw bytes unchanged; its explicit inert web API fallback adds 296 raw / 137 gzip bytes with unchanged reachability.

Runtime-routed Checks revision stream

Automatic runtime-routed SSH Checks now keeps its existing three-second visible fallback until the normal and reuseLineStats streams represent the same live provider incarnation and a ready event drives an admissible current-context snapshot read. After that admission, idle snapshot polling stops; any incarnation mismatch, invalidation, replay, disconnect, error, visibility/context change, or malformed/inadmissible snapshot immediately fails open.

One visible idle minute after readiness Before Current
Normal identity snapshot RPCs / owner reads 20 / 20 0 / 0
reuseLineStats fallback RPCs / owner reads 40 / 40 0 / 0
Physical status / upstream producer work 1 / 1 1 / 1

Independent review reproduced and corrected a cross-socket ordering gap where one stream could advance to provider incarnation 5 while its sibling remained at 4. The retained implementation pairs both live incarnations before admission, preserves the fail-open loop, passes 220 focused tests across 16 files plus type/lint/format/max-lines/build/budget gates, and records exact A/B evidence in tools/benchmarks/results/phase2-runtime-checks-repository-snapshot-revision-stream-2026-07-30.md.

Initial mobile diff review

The first automatic mobile diff-review load now queries the exact default
git.repositorySnapshot projection published by mobile Source Control before falling back to
its existing fresh git.status request. Admission requires complete, untruncated,
current-generation status, repository-identity, and conflict siblings with one matching identity;
upstream data is ignored because this surface needs only entries, head, branch, and conflict state.

Settled Source Control status followed by diff review Before Current
Native/exact-WSL physical status loads 2 1
SSH git.status provider/mux requests 2 1

Only the first connected load for a client, host, and worktree context may use the projection.
Initial disconnected states preserve that opportunity; later reconnects, mutation reloads, retries,
explicit refreshes, reconciliation, PR preparation, and every later diff-review load remain fresh.
The separately bounded Source Control remount consumer is described below.
Old-runtime, disconnected, missing, malformed, stale, truncated, generation-mismatched, and
identity-mismatched projections immediately retain the existing fallback and unavailable copy.

The mobile consumer adds no Electron renderer code. The mobile RPC allowlist changes Electron main
by 0 raw / -1 gzip byte versus the prior checkpoint; preload and the complete renderer tree are
byte-identical, with unchanged 292/77/33 JS reachability for index/popout/web.

Initial mobile Source Control remount

The first connected automatic load for each mounted mobile Source Control client and default
status-identity context now queries the runtime-owned git.repositorySnapshot projection before
its existing fresh git.status fallback. Admission additionally requires a fresh configured-upstream
projection with non-negative integer counts, a nonempty name when upstream exists, and the exact
configured no-upstream shape. Status, repository identity, and conflicts remain complete,
untruncated, current-generation, and identity-equal; upstream shares the generation without assuming
the status identity.

Source Control → diff review → Source Control remount Before Current
Native/exact-WSL physical status loads 2 1
SSH git.status provider/mux requests 2 1
Read-only owner snapshot queries 1 3

Cold, rejected, malformed, stale, old-runtime, or unavailable projections pay one best-effort query
and retain the fresh selector-retrying path. Disconnected-first and StrictMode preserve/coalesce the
single opportunity; reconnects and every explicit, retry, refresh, forced, mutation, branch,
reconciliation, and PR safety load stay fresh. Render-current client, connection, identity, mount,
and generation guards suppress late commits. The parser now lives at an acyclic Source Control domain
boundary shared with diff review.

This mobile-only tranche leaves Electron main, preload, and all renderer trees byte-identical, with
the same 779-record manifest and zero missing paths, missing edges, escaping paths, or static cycles.

Workspace Space Manager snapshot reuse

After automatic Workspace Cleanup warms the existing repository owner without populating renderer gitStatusByWorktree, Space Manager now queries the exact normal and reuseLineStats projections before its existing six-worker fresh-status fallback. It selects the newest admissible status revision and applies status, repository identity, conflicts, and configured-upstream evidence only while the analyzed row, branch, connection/provider incarnation, runtime target, mount, and missing-status claim remain current.

Cleanup followed by Space Manager for one eligible row Before Current
Native/exact-WSL physical status work 2 1
SSH provider/mux git.status work 2 1
Configured-upstream computation embedded in status 2 1
Separate upstream work 0 0
Repository-owner memory reads 0 2
Desktop runtime RPCs 0 0

Cold, stale, malformed, truncated, identity-mismatched, old-runtime, disconnected, or ambiguous projections retain the existing fresh path. Independent review corrected two liveness boundaries before publication: a fresh fallback can finish its own identity/upstream writes after claiming the missing status entry, and a connection-only SSH provider replacement aborts the old request and schedules a new one with the replacement connection. Folder/main exclusions, explicit refreshes, active polling, mutations, Workspace Cleanup reads, and authoritative deletion preflights are unchanged.

Electron main and preload remain byte-identical. The final renderer index changes by +67 raw / -169 gzip bytes, popout by 0 raw / -47 gzip, and web by 0 raw / +5 gzip, with unchanged 292/77/33 JS reachability and unchanged CSS counts.

Source Control automatic-upstream snapshot reuse

After a settled active poll while Explorer, Checks, or an editor already keeps Git status interactive, switching to Source Control now queries the exact normal and reuseLineStats owner projections before the existing fresh upstream fallback. The consumer selects the newest admissible status revision and applies configured-upstream evidence only while worktree, path, branch, push target, SSH provider incarnation, runtime target, visibility, and mount remain current.

Settled poll followed by Source Control tab switch Before Current
Native/exact-WSL physical status work 1 1
Configured-upstream computations 2 1
Separate native/exact-WSL upstream work 1 0
SSH provider/mux git.status work 1 1
SSH provider/mux git.upstreamStatus work 1 0
Repository-owner memory reads 0 2

Runtime routing changes total Git RPCs from two to three (git.status 1→1, git.upstreamStatus 1→0, git.repositorySnapshot 0→2) while reducing physical runtime upstream work from one to zero. Cold, stale, malformed, truncated, branch-mismatched, old-runtime, disconnected, failed, or otherwise inadmissible projections retain the fresh path; explicit refreshes, mutations, reconciliation, polling, Workspace Cleanup, review-safety reads, and deletion preflights remain unchanged.

Independent review replaced literal-only A/B counters with call-instrumented measurements. The final ten-file focused suite passed 123 tests, the relevant host/routing suite passed 154 tests, and the broad renderer suite passed 1,913 tests; web/node typechecks, lint/format, max-lines, production build, budgets, and complete manifest/path/static-cycle validation passed. Electron main and preload remain byte-identical; renderer index changes by +2 raw / +10 gzip bytes, with unchanged 292/77/33 JS reachability and unchanged CSS counts.

Validation completed for this checkpoint

  • 84 settled Orca orchestration tasks, including per-tranche strict A/B builds and independent checkpoint/evidence audits.
  • Fresh exact-tree production builds and bundle-budget checks.
  • Root Node/CLI/web typechecks and mobile typecheck across the broader stacked checkpoint.
  • Aggregate lint/format checks plus targeted oxlint --deny-warnings and oxfmt --check for this tranche.
  • Max-lines ratchet with no new bypasses.
  • Complete renderer manifest/path/static-cycle validation for baseline and retained builds.
  • Tracked and untracked whitespace checks.
  • This tranche's focused acceptance set passed 75 tests.
  • Its broad host suite passed 376 tests with one skip; its broad renderer suite passed 121 tests; the core IPC registrar suite passed two tests.
  • The Delete Worktree status-projection suite passed 30 tests; its broad owner/native/WSL/SSH/removal/dialog suite passed 611 tests with two skips.
  • The runtime-query tranche passed 106 focused tests and 91 web preload tests; its broad host suite passed 663 tests with one skip and its broad renderer suite passed 110 tests.
  • The initial mobile diff-review tranche passed 22 focused mobile tests, 66 broader mobile route/Source Control tests, and 42 host/RPC tests; all affected typechecks and static gates passed.
  • The mobile Source Control remount tranche passed 64 focused mobile tests, 1,083 broad Source Control/session tests, and 42 host/RPC tests; all typechecks, static gates, a fresh production build, budgets, and exact-tree validation passed.
  • The Workspace Space Manager tranche passed 59 focused consumer tests, 46 snapshot/hook/refresh acceptance tests, 251 relevant host-boundary tests, and 1,871 broad renderer tests; web/node typechecks, lint/format, max-lines, a final production build, budgets, and exact manifest/path/static-cycle validation passed.
  • The runtime Checks revision-stream tranche passed 220 focused tests across 16 files; node/web typechecks, targeted lint/format, max-lines, a fresh production build, budgets, and complete A/B manifest/path/reference/static-cycle validation passed.

Known unresolved risks

  • No packaged-ASAR launch matrix has yet run across macOS, Linux, and Windows.
  • Linux glibc/native-module packaging compatibility still requires the real packaging gate.
  • Mobile process-memory evidence still needs physical-device validation.
  • Initial mobile snapshot reuse still needs live-device and packaged reconnect latency sampling.
  • Lazy first-use latency and stale-chunk recovery need runtime smoke coverage.
  • The dashboard popout still inherits the eager root-store closure; the small extraction audit was rejected.
  • Rolldown currently promotes shared static renderer utilities when small app-overlay visuals become dynamic, so further micro-UI splits need allocation evidence before retention.
  • This intentionally large stacked checkpoint is behind current main and will need conflict/review decomposition before merge.

Next measured work

Measure the next bounded host-owned repository consumer or runtime transport seam, then retain it only with a concrete physical-work reduction and a narrow fallback contract. Preserve native, exact-distro WSL, SSH incarnation, runtime, folder-workspace, provider, explicit push-target, cancellation, mutation-fence, and Git 2.25 behavior. Avoid additional renderer micro-UI splits that share the promoted Lucide/cn utility graph unless a measured allocation model first proves no popout or web regression.

@nwparker

Copy link
Copy Markdown
Contributor Author

Closing: ~37k lines bundling several unrelated systems, stale since July. Split any surviving piece into a focused PR with a measured gain.

@nwparker nwparker closed this Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant