Skip to content

perf(cli): overlap the API compatibility check with the install - #748

Merged
Kamirus merged 1 commit into
v3from
kamil-claude/install-api-check-overlap
Aug 13, 2026
Merged

perf(cli): overlap the API compatibility check with the install#748
Kamirus merged 1 commit into
v3from
kamil-claude/install-api-check-overlap

Conversation

@Kamirus

@Kamirus Kamirus commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Every mops install serialized behind the API compatibility check — a registry round trip worth ~110 ms — before downloading anything. The check now runs concurrently with the install and is awaited after it. Closes out item 31 of #723 together with #747.

The outcome of the check is unchanged: an incompatible CLI still prints the same error and skips the toolchain install. What changes is ordering — the install completes before the version error surfaces, which #723 judged acceptable given the guard is already nominal (build, check, test, bench, generate, sources and add never check at all). The promise is settled into a thunk immediately, so a check that rejects mid-install cannot surface as an unhandled rejection; awaiting the thunk rethrows exactly where the serial code used to throw (verified against a dead registry endpoint: exit 1, no UnhandledPromiseRejection).

mops publish deliberately keeps its check serial and now carries a comment saying so: publishing writes immutable registry state, so the version gate must hold it back.

HTTP/2: measured, not adopted

The remaining strand of item 31 suggested an undici Agent({ allowH2: true }) so concurrency could rise while connection pressure falls, with the instruction to measure rather than assume. Measured (16 concurrent requests against icp-api.io, cold pool, medians of repeated runs):

configuration wall time connections
h1, unbounded pool (today) 65–130 ms 16 × http/1.1
h2, unbounded pool 68–98 ms 16 × h2
h2, connections: 1 (multiplexed) 184–228 ms 1 × h2
h1, connections: 1 258 ms 1 × http/1.1

The boundary nodes do negotiate h2, but undici only multiplexes when the connection pool is capped, and capping is 2–3× slower on a healthy network — the cold-process TLS handshakes the idea meant to eliminate run in parallel, so 16 of them cost roughly one RTT of wall time, not 16. An uncapped h2 pool still opens one socket per in-flight request and gains nothing. The connection-pressure scenario h2 would help (low fd limits, constrained containers) is the one #747's fd-aware budget and halved-budget retry already cover. Against that, adopting it means bundling undici into the CLI (the bun bundle inlines dependencies) and taking on undici's h2 maturity risk. Not worth it on this evidence; the measurement script is small and rerunnable if boundary-node behavior changes.

🤖 Generated with Claude Code

The check costs a registry round trip (~110 ms) that every
`mops install` serialized behind. It now runs concurrently with the
install and is awaited after it, settled into a thunk so a rejection
during the install cannot become an unhandled rejection. The outcome
is unchanged - an incompatible CLI still errors and skips the
toolchain install - but the error surfaces after the packages have
installed, which #723 judged acceptable given build/test/sources
never check at all. `mops publish` keeps its check serial: it writes
immutable registry state.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Cursor AI review

👍 APPROVE — looks safe to merge

Category Assessment Details
Summary Overlaps checkApiCompatibility() with installAll on mops install so the ~110 ms registry round trip no longer serializes the install; mops publish stays serial; changelog documents the post-install error ordering.
Code Quality Small, purposeful change: thunk settlement avoids unhandled rejection; no speculative helpers; publish path left alone with an explicit rationale comment.
Consistency Matches stated CLI philosophy (install-path perf, publish more conservative); ## Next Performance changelog entry present; no flag/docs/skill surface change required for this internal ordering.
Security Traced checkApiCompatibilitymainActor/getAgent in cli/api/actors.ts (shared agent already used for parallel install traffic); toolchain install still gated on compatibility; publish still awaits the check before writing registry state; integrity/auth paths untouched.
Tests ⚠️ No new tests or snapshot updates; checkApiCompatibility ordering/rejection path was already untested (no hits in cli/tests). Gap is acceptable given the tiny control-flow change and author’s stated dead-endpoint check.
Maintainability Comments in cli/cli.ts document why install overlaps and why publish must not; changelog states the user-visible ordering tradeoff clearly.

Verdict

Decision: APPROVE
Risk: Low
Reason: Intended, well-contained reordering of an already-nominal install-time API gate; happy-path outcomes match base, toolchain and publish remain gated, and the rare incompatible-CLI install-before-error behavior is documented and consistent with other commands that never check.


Generated for commit 5c0cea5

@automation-sa-sre automation-sa-sre left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated approval: the AI review verdict for 5c0cea5 is APPROVE. See the "Cursor AI review" comment for details.

@Kamirus
Kamirus merged commit 825b7a8 into v3 Aug 13, 2026
20 checks passed
@Kamirus
Kamirus deleted the kamil-claude/install-api-check-overlap branch August 13, 2026 12:12
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.

2 participants