perf(isolator): run per-capsule installs sequentially instead of all at once#10457
perf(isolator): run per-capsule installs sequentially instead of all at once#10457davidfirst wants to merge 4 commits into
Conversation
When rebuilding scope-aspects capsules with nesting enabled, each capsule was installed via its own separate package-manager install. For a cold rebuild of many capsules this means N separate installs that each re-resolve a heavily-overlapping dependency tree and serialize on the pnpm store lock (~6m for 5 env capsules). When more than one capsule needs installing, fall back to a single batched install; capsule isolation is preserved via rootComponentsForCapsules (~1m for the same 5 capsules). The single-capsule incremental path is unchanged.
PR Summary by QodoBatch-install capsules when nesting enabled to avoid N installs Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1.
|
…capsule-install # Conflicts: # scopes/component/isolator/isolator.main.runtime.ts
|
Code review by qodo was updated up to the latest commit dfd76c7 |
Batching multiple scope-aspect capsules into a single install breaks the per-capsule dependency isolation the e2e suite enforces (deps-in-capsules, root-components). Direct-dep placement is fixable via pnpm hoistPattern/ dedupeDirectDeps, but per-capsule peer/version isolation (two versions of the same aspect needing different peers) leaks in a shared install. Per-capsule nesting is required for correctness, so revert to master's behavior.
|
Code review by qodo was updated up to the latest commit 3dba919 |
…at once Each scope-aspect/env capsule is installed in its own package-manager install, previously all fired at once via Promise.all. These installs serialize on the pnpm store lock, so full concurrency mostly thrashes (CPU oversubscription + lock contention) and is actually slower than running them one at a time. Cap the per-capsule install concurrency (1 = sequential): faster wall-clock and far less CPU, with isolation unchanged.
|
Code review by qodo was updated up to the latest commit 262ff2c |
Scope-aspect/env capsules are each installed in their own package-manager install. They were all fired at once via
Promise.all, but these installs serialize on the pnpm store lock, so full concurrency mostly thrashes (CPU oversubscription + lock contention) and ends up slower than running them one at a time.This caps the per-capsule install concurrency to 1 (sequential). On a cold rebuild of 5 env capsules it's both faster and far lighter on CPU:
Promise.all(all at once): ~7m41sLower CPU matters on CI where other jobs share the box. Isolation is unchanged — these are the exact same per-capsule installs, just throttled (kept as a named constant so the value is easy to tune).
Why not batch into one install
The original idea here was to batch all capsules into a single install to skip the repeated resolution. That breaks per-capsule isolation: capsules are loaded and executed at runtime, so each must resolve its own dependency tree (including peers like React) to the exact versions it needs. A single shared install hoists/unifies deps across capsules — caught by the
deps-in-capsulesandroot-componentse2e tests (e.g. two versions of the same aspect resolving the wrong React). Direct-dep placement was fixable with pnpm hoisting flags, but per-capsule peer/version isolation wasn't, so the batching approach was dropped in favor of this safe concurrency change.