Skip to content

perf(startup): overlap desktop loading and defer provider work - #9893

Open
maria-rcks wants to merge 7 commits into
pingdotgg:mainfrom
maria-rcks:t3code/speedup-desktop-startup
Open

perf(startup): overlap desktop loading and defer provider work#9893
maria-rcks wants to merge 7 commits into
pingdotgg:mainfrom
maria-rcks:t3code/speedup-desktop-startup

Conversation

@maria-rcks

@maria-rcks maria-rcks commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

desktop startup previously serialized renderer loading behind the backend and eagerly initialized provider libraries. this pr loads the bundled renderer while the backend starts, gates authentication on actual readiness, caches compilation, bundles the desktop runtime, and defers provider clients/schemas and optional native imports.

five alternating linux launches per variant with the same isolated project/state and warm compilation caches show an additional meaningful improvement over the previously green head (ac3756f):

milestone previous head 6896cd3 reduction
desktop window shown 1.087 s 0.928 s 14.6%
desktop project and editable composer 4.213 s 3.695 s 12.3%
actual vp run dev, vite and backend accepting commands 3.929 s 3.692 s 6.0%

half a second for a usable composer was not achieved. these are warm-cache measurements; initial cache population is excluded. earlier passes separately measured desktop 5.605 → 5.140 s and then 5.081 → 4.006 s; those runs used different baselines and are not combined into a single percentage.

verified scoped lint/format, desktop and server typechecks/builds, existing codex adapter/driver and acp tests, and 117 focused existing tests covering turn validation, shell capture, backend, window, and protocol behavior. native linux checks exercised typing, settings, reload, cache disabled/invalid-path fallback, normal quit cache persistence, automatic recovery after a 65-second backend pause, and early close followed by explicit activation. the early-close check retained the linux process to exercise the macos-style window lifecycle. a /proc cache override stalls plain node before application code too; normal invalid-directory fallback passed. native macos, windows, and wsl timings remain unverified; wsl-only retains its existing startup path.

native desktop startup comparison, previous head and final

full-resolution recording · raw alternating measurements

the test-only follow-up eec1e06 waits for real probe signals in two existing tests; all 48 provider registry tests pass. production artifacts and benchmark evidence are unchanged.

model: gpt-5.6-sol, codex harness, with parallel implementation agents and two independent final reviews.

Note

Defer provider SDK imports, overlap desktop loading, and add Node compile cache

  • Changes Codex, Claude, and ACP provider modules to type-only imports at the top level and loads SDKs dynamically during runtime usage. Import failures surface as specific spawn or process errors instead of failing at module evaluation.
  • Overlaps desktop startup by forking Linux URL-handler registration, serving bundled static renderer files through the desktop protocol, and creating the main renderer while the backend starts.
  • Adds NODE_COMPILE_CACHE to the dev runner and desktop backend environment to speed up module loading.
  • Fixes the DesktopWindow lifecycle by serializing concurrent ensureMain calls with a semaphore and tracking intentional window closure to stop backend readiness from auto-reopening it.
  • Risk: Provider SDK load failures now return CodexAppServerSpawnError, ProviderAdapterProcessError, or AcpTransportError; desktop auth waits for backend readiness and returns DesktopLocalEnvironmentAuthBackendStoppedError if readiness fails.

Macroscope summarized eec1e06.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Sep 5, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Sep 5, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This PR changes default desktop startup, renderer serving, authentication timing, window lifecycle, and provider initialization across multiple production components. It also adds a directive suppressing a static-analysis diagnostic, so the scope and review-sensitive configuration warrant human review.

Notes:

  • No code objects were reviewed. Approvability was decided on eligibility alone.

You can add or adjust custom eligibility rules. Learn more.

@macroscopeapp
macroscopeapp Bot dismissed their stale review September 5, 2026 05:28

Dismissing prior approval to re-evaluate 69aaa3a

@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels Sep 5, 2026
@maria-rcks maria-rcks changed the title perf(startup): reduce desktop imports and cache dev compilation perf(startup): overlap desktop loading and defer provider work Sep 5, 2026
Comment thread apps/desktop/src/electron/ElectronProtocol.ts
Comment thread apps/desktop/src/backend/DesktopLocalEnvironmentAuth.ts Outdated
Comment thread apps/desktop/src/backend/DesktopLocalEnvironmentAuth.ts
@github-actions github-actions Bot added size:XL 500-999 changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). labels Sep 5, 2026
Comment thread apps/server/src/provider/Layers/CodexSessionRuntime.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant