Skip to content

perf(server): source control discovery runs its probes in parallel - #43651

Open
juliusmarminge wants to merge 1 commit into
mainfrom
perf/source-control-discovery-parallel
Open

juliusmarminge wants to merge 1 commit into
mainfrom
perf/source-control-discovery-parallel

Conversation

@juliusmarminge

Copy link
Copy Markdown
Member

server.discoverSourceControl takes 2–4 s on every call. Fleet traces for stable 0.1.12 over 24 h: 833 web calls, all ≥1.07 s, 732 of them in the 2.1–4.3 s bucket. Every Git controls mount and command palette open pays it.

Cause

A 4.0 s sample trace from a host with az installed:

start duration command
+0 ms 238 ms login shell PATH refresh
+429 ms 311 ms git --version
+868 ms 2,552 ms az --version
+3,421 ms 601 ms az account show (starts when az --version ends)

Two waits are in series:

  1. Since fix(server): source control discovery no longer runs the auth command of a CLI that is not installed #42379, probeSourceControlProvider runs a CLI's auth command only after its version command answers. That PR also added the PATH check, so CLIs that aren't installed are never spawned anyway. For az the wait adds 0.6 s to the 2.5 s version probe. gh and glab show the same version-then-auth chain.
  2. SourceControlDiscovery combines the VCS probes and provider discovery with Effect.all on a record without concurrency, so the forge probes started only after git --version finished (+741 ms in the trace).

Fix

  • Once a CLI is found on PATH, its version and auth commands now run at the same time. Auth is still ignored when the version probe fails. One exception: a spec with rejectedVersionMeansMissing (gt, which may be Graphite) still waits for the version probe before it asks auth.
  • VCS and provider discovery run concurrently.

The total is now bounded by the slowest single command. On the sample trace that is about 2.8 s instead of 4.0 s. az --version itself is still the floor on hosts with Azure CLI installed.

Trade-off: a CLI that is on PATH but fails to start now costs two failed spawns instead of one. The GitLab test from #42379 now asserts the reported result instead of the spawn count. CLIs that are not on PATH still spawn nothing, and spawns nothing for a glab that is not on PATH still covers that.

Tests

  • New SourceControlDiscovery.test.ts case, answers once the slowest probe does…, uses TestClock delays: git 1 s, CLI version 3 s, CLI auth 1 s. It asserts discovery has finished after 3 s. It fails on main, where the serial chain takes 5 s.
  • vp run check:changed passes. The apps/server/src/sourceControl tests pass, and so do the gitlab, forgejo, github, gitcafe, azure-devops, tanstack-source and cursor-origin package tests.

Opus 5.5 via Claude Code

🤖 Generated with Claude Code

Each forge CLI's auth command waited for its version command, and provider
discovery waited for the git/jj version probes. With Azure CLI installed,
`az --version` (~2.5 s) and then `az account show` (~0.6 s) ran in series
behind `git --version`, so every call took 3-4 s.

Once a CLI is found on PATH, its version and auth commands now run
together (a `gt` that may be Graphite still waits for its version probe),
and VCS and provider discovery run concurrently.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅
Claude Live turn messages 1 1 0 (0.0%) 8 ✅

Other scenarios

All 64 scenario measurements match main.

All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling
Codex short turn resume WebSocket decoded 10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅
Codex short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn running, cold open HTTP decoded 281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅
Codex long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Codex long turn running, history page HTTP decoded 92.4 KiB 92.4 KiB 0 B (0.0%) 107.4 KiB ✅
Codex long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Codex long turn finished, cold open HTTP decoded 381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, socket cold open WebSocket decoded 381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, work page HTTP decoded 186.2 KiB 186.2 KiB 0 B (0.0%) 200.2 KiB ✅
Codex long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Codex idle thread resume WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell snapshot HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Codex fleet shell subscribe WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Codex fleet shell resume check rows 0 0 0 0 ✅
Codex stale shell reload HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex stale shell reload rows 27 27 0 (0.0%) 27 ✅
Codex stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Codex stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex stale todo list cold open HTTP decoded 72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅
Codex stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Codex stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅
Claude short turn resume WebSocket decoded 10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅
Claude short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn running, cold open HTTP decoded 283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅
Claude long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Claude long turn running, history page HTTP decoded 93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅
Claude long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Claude long turn finished, cold open HTTP decoded 384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, socket cold open WebSocket decoded 384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, work page HTTP decoded 188.1 KiB 188.1 KiB 0 B (0.0%) 200.2 KiB ✅
Claude long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Claude idle thread resume WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell snapshot HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Claude fleet shell subscribe WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Claude fleet shell resume check rows 0 0 0 0 ✅
Claude stale shell reload HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude stale shell reload rows 27 27 0 (0.0%) 27 ✅
Claude stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Claude stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude stale todo list cold open HTTP decoded 73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅
Claude stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Claude stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅

Baseline: 28e9072 · PR result: 5082cc7 · 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.

@coderabbitai

coderabbitai Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Discovery now waits for PATH refresh before running VCS probes and provider discovery. CLI discovery handles missing executables and version-probe failures with missing results and unknown authentication. Version and authentication probes can run concurrently for installed CLIs.

Changes: Source control discovery

Layer / File(s) Summary
CLI probe outcomes
packages/source-control-core/src/server/discovery.ts, packages/source-control-gitlab/src/server/gitLabDiscovery.test.ts
Missing executables return a missing result with unknown auth without spawning probes. For installed CLIs, version and auth probes run concurrently unless rejectedVersionMeansMissing is true. In that case, auth runs only after an available version result. The GitLab test covers an on-PATH CLI that fails to start.
PATH refresh and discovery
apps/server/src/sourceControl/SourceControlDiscovery.ts, apps/server/src/sourceControl/SourceControlDiscovery.test.ts
Discovery waits for refreshPath before running VCS probes and provider discovery concurrently. A virtual-time test checks probe timing and completion.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant Discovery as SourceControlDiscovery.discover
  participant Refresh as refreshPath
  participant VCS as VCS probes
  participant Providers as provider discovery
  Discovery->>Refresh: refresh PATH
  Refresh-->>Discovery: refreshed PATH
  par
    Discovery->>VCS: run VCS probes
  and
    Discovery->>Providers: discover providers
  end
  Providers->>CLI: discover CLI
  participant CLI as CLI discovery
  par
    CLI->>Version: probe version
  and
    CLI->>Auth: probe authentication
  end
  participant Version as version probe
  participant Auth as auth probe
Loading
Merge Risk: Minimal · up to 5082c

This change reduces source control discovery latency by running version and auth probes together. It keeps missing-CLI and failed-version results reported as missing with unknown auth. No actionable merge risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: source control discovery now runs its probes in parallel, with a conventional perf(server) prefix. It matches the summarized changes to SourceControlDiscovery and the …
Description check Passed The description follows the template structure. It has Problem (slow server.discoverSourceControl calls, with fleet data), Change (cause and fix), Scope (references the prior PR #42379 and the reason …
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 names the main change: source control discovery now runs its probes in parallel, with a conventional perf(server) prefix. It matches the summarized changes to SourceControlDiscovery and the CLI discovery logic, which run version and auth probes concurrently and VCS and provider discovery concurrently.

Full details: Description check

Explanation

The description follows the template structure. It has Problem (slow server.discoverSourceControl calls, with fleet data), Change (cause and fix), Scope (references the prior PR #42379 and the reason the change is a bug fix, though no issue link is given), and Verification (named test case, check commands, and results). It does not include a fully linked issue, and it says the tests pass without a repo-wide check, which the template accepts.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 28e9072 and 5082cc7.

Files selected for processing: 4

  • apps/server/src/sourceControl/SourceControlDiscovery.test.ts
  • apps/server/src/sourceControl/SourceControlDiscovery.ts
  • packages/source-control-core/src/server/discovery.ts
  • packages/source-control-gitlab/src/server/gitLabDiscovery.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted 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