Repository navigation
perf(ci): remove shadow planning from the PR critical path - #37699
Conversation
Audit every job in PR #37692; defer shadow planning off the required path and align transform-cache producers with hosted ARM consumers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
PR CI speed auditDelivered: #37699, CI-only and fully green on Evidence and success criterionReference: PR #37692, head
Success: reduce the required PR critical path without reducing meaningful assertions, runtime isolation, platform coverage, or fail-closed routing. Validate matrix/selection/cache regressions, the changed gate, a fresh PR run, and a same-source cold/producer/warm comparison. A later PR is not a controlled benchmark of total latency: changed paths, source, queueing, and caches can differ. Where time goesThe required gate completed at 05:58:02Z, 573 seconds after workflow creation at 05:48:29Z. The advisory selection report finished later and did not block merging. The main chain was detection (14s), unit planning (64s), shard scheduling/setup, the slowest shard (475s including 43s checkout), and the aggregate gate (5s). Linux and Windows packaging finished earlier, at 05:55:27Z and 05:55:24Z. Static analysis finished at 05:52:26Z. Unit files: 13,126; 12 independent 4-vCPU ARM runners. Each file has an isolated worker. Worker startup summed to 1,138 seconds, NOT wall time. Module phase sums: collection/import 11,231s; test bodies 4,618s; setup 364s; environment 263s; preparation 33s. Vitest's separate summary attributes roughly 40-44% to imports and 25-30% to transforms, with bodies roughly 25-30%. These measurements overlap and must not be added to wall time. All 12 transform-cache restores missed. No Dynamic selection is not an immediate solution: the shadow graph selected 11,653/13,126 files (88.8%) for this six-file settings change. Every ownership record was invalid for the current context ( Every reference jobDurations below are runner job elapsed times, not sum of steps. Background steps overlap.
Static analysis, step by stepCheckout (23s) and root dependencies (19s) are serial overhead. Bun setup is tiny. Early checks deliberately overlap; their elapsed times cannot be summed:
The source already contains substantial static-check optimization. Its 214s does not set this PR's 573s required path. Do not trade type safety or platform gates for optimizing a noncritical lane. Test value and opportunitiesThe highest total module cost is often import cost, not assertion count. Examples: runtime RPC mobile streaming (~44.5s collection), restored-consumer journeys (~43.1s), orchestration federation output (~40.4s), settings browser-profile cookie clearing (~40.2s). Slow bodies include structured-chat mail scaling (~50.5s), Claude helper recovery (~33.7s), CLI account subprocess (~33.6s), remote runtime download (~31.3s), Codex interrupt/settings (~30s). These drive real state machines, persistence, process cleanup and compatibility. Mail scaling tests intentionally observe absence of repeated work across backlogs; shortening observation windows without understanding timers would weaken them. No tests deleted on the basis of names, duration, or mock count alone. Existing repository anti-pattern guidance rejects source-string inventories and self-fulfilling mocks, but this audit found the critical path is primarily isolated import/transform overhead, not proof that the slow behavioral tests are valueless. Vitest's Increasing shard count is not the first fix: 12 is already balanced at 1,093-1,094 files each; more shards consume more slots, replicate installs, and multiply caches. A balanced timing baseline should come from representative complete runs, not one noisy run. Packaging assessmentLinux is not just a build. It checks daemon descendants, dual-Electron lifecycle, three real distro formats, root-package markers, AppImage-pinned Node, hostile launch environments and signal cleanup. Removing that coverage because a PR changes renderer code would hide packaging regressions in code that still ships. The 15 lifecycle files are intentionally serialized because parallel probes have exceeded deadlines on four cores. Docker image loading, native helper work and JS/web builds already overlap safely. Windows' largest block is 83 platform-boundary files plus an isolated loaded tree-kill probe. It exercises real ACLs, native jobs, PTY, Unicode launcher/hooks, registry and process inheritance. It installs/extracts Electron once to prevent concurrent EBUSY/crashes and shares Rust binaries. Building starts after tests because Node/Electron native ABIs mutate the same outputs. Do not overlap those phases blindly. Both packaging jobs can become the next critical path once unit latency drops enough. Optimize only with platform-native evidence; this macOS workstation cannot honestly reproduce their native timing. Implemented scope
Validation checkpointsPR: #37699
Controlled cache resultComparison run 41588931783 succeeded on the same source Validated every downloaded shard artifact, not just the workflow verdict: all 36 shards passed, all lanes covered the identical 13,127-file discovery inventory exactly once, assignment/results matched, source hashes and Node 24.22.2 / Bun 1.4.4 / Vitest 5.0.5 matched, and there were no unhandled errors or omitted diagnostic files. All 12 warm archives restored and passed validation, and their identities and producer source hashes matched. This source is the branch head rather than the later PR merge, hence the different inventory count.
Warm versus baseline: 48s / 12.6% lower median test time, 43.5s / 10.1% lower median whole-job time, and 42s / 8.8% lower maximum whole-job time. The slowest test step fell 49s / 11.6%. Ten shards' test steps improved, one tied, and one regressed 3s. This is one controlled source/run, not a confidence interval or a guarantee for every future PR.
Warm overhead was bounded: restore 2–4s, validation 3–4s, identity 0–1s per shard. Producer sealing took 3–4s and saving 3–5s. Summed collection/import worker time fell from 11,403.7s to 9,638.8s (15.5%); these are worker totals, not wall time. Assertions still ran in isolated workers. One generation: 5,835,108,923 raw bytes, 1,529,043,588 compressed bytes across 12 archives, each approximately 20–26k entries. All 12 experiment cache IDs were individually matched to their producer identities, branch ref and run suffix before deletion; no shared/main/dependency caches were selected. Artifacts and the measurement summary remain available for review. Compute is not free: producer jobs summed to 86.9 runner-minutes, versus 86.4 baseline and 78.9 warm. At the observed 7.6 runner-minutes saved per full warm PR, one daily producer amortizes after roughly 12 warm full-PR runs, excluding configuration-triggered refreshes and queue effects. This is another reason to use daily rather than three-hourly production. The comparison predates only the warm-miss optimization and daily schedule: warm-hit/cache validation behavior is unchanged. The final production workflow has not run on main before merge. Daily refresh limits duplicate generations; the remaining ~5–8 minute unit work is still substantial. Further large gains require reducing expensive runtime import graphs or trustworthy ownership/selection evidence, not deleting meaningful assertions or globally sharing worker state. Final integration checkpointThe schedule-only follow-up, run 41591659826, exposed an unrelated new main regression in The existing focused upstream repair, #37711, supplies Final post-integration validation of The final planner took 7s; advisory rebuilding/comparison took 47s outside the gate and independently confirmed the complete 13,142-file merge inventory against All 14 |
Walkthrough
Merge Risk:
|
…terpolation Pass the workflow boolean through the step environment so the credential-removal and failure-propagation contract can execute both comparison paths directly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The measured 12-shard generation occupies 1.42 GiB compressed. Keep immediate configuration refreshes without churning the cache quota eight times daily. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| on: | ||
| workflow_dispatch: | ||
| schedule: | ||
| - cron: '23 3 * * *' |
There was a problem hiding this comment.
Keep push-trigger coverage aligned with cache policy inputs.
The daily schedule changes cache refreshes from every three hours to once per day. However, moduleCachePolicyHash() also hashes workspace package.json files, nested tsconfig*.json files, and config/dark-build-switches.cjs, while on.push.paths does not include all of these inputs. A change to an omitted file changes the cache identity without starting a producer, so warm PR jobs can miss the cache for almost 24 hours. Add the complete policy-input paths to on.push.paths. (github.com)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep producer and benchmark storage behavior unchanged from main. Do not add a daily 1.42 GiB cache generation to a near-quota cache store without retention and eviction evidence. Reuse existing draft selection artifacts instead of rebuilding the graph twice. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Review: useful speedup retained; unbudgeted caching removedReviewed the entire retained diff, reusable workflow callers, full/selected matrix routing, shard discovery and provenance fallback, advisory completeness, cache identity/validation, consumer writes, producer saves and cleanup.
No unresolved correctness finding remains in the retained changes. Existing dispatch-only cache experiments are not a budgeted production rollout and are not enabled automatically. Resource/performance coverage
Final evidence
|
Follow-up to #37699: pr.yml computes defer_shadow once, unit-plan.yml uses only that input and exposes selection_planned, and the test and evidence jobs read that output instead of repeating the condition.
ELI5
Start all PR tests without spending a minute deciding to run all of them. Full planning fell from 64s to 7-17s in hosted validation. Preserve the same tests and isolation, and stop writing disposable compile caches on cache misses.
What Changed
Why
Audited every job in #37692. Its required gate took 573s: unit planning spent 64s on checkout/dependencies/shadow analysis before the 12 full shards could start. Packaging finished around 6m35s; static analysis took 214s. Module imports/transforms dominate unit cost. Shadow selection still selected 11,653/13,126 files for a small renderer change, with no valid current ownership records. Removing tests or sharing worker state was not justified.
The controlled cache comparison demonstrated a 10.1% lower median whole-shard time on the same source, but also exposed the storage and producer costs: 1,529,043,588 compressed bytes per generation and 86.9 producer runner-minutes, amortizing after about 12 warm full-PR runs. The repository currently stores about 9.44 GB / 8.79 GiB of Actions caches. Daily refresh is not a storage bound: immutable generations accumulate and can evict useful dependency caches. Therefore automatic production is not included, and the benchmark's warm-hit savings are not claimed as a shipped improvement.
The retained planning optimization removes serial setup and artifact work without adding a periodic full-suite producer. The cache-miss fix only removes consumer-local writes that were never uploaded.
The complete original per-job audit includes the static-check breakdown, test-value review, upstream source findings, cache sizes and per-shard measurements. This description supersedes its earlier proposed cache rollout.
Linked Issue
If you do not have one and are an outside contributor, your PR will be ignored. Refs is not sufficient. Link an actual issue
None linked; requested CI audit using #37692 as the reference.
Visual Proof
N/A - CI orchestration only; no application UI changes.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
ORCA_BACKGROUND_LAUNCH=1 pnpm test config/scripts/ci-unit-module-cache.test.mjs config/scripts/ci-unit-module-cache-contents.test.mjs config/scripts/ci-unit-plan.test.mjs config/scripts/ci-unit-selection-review.test.mjs config/scripts/ci-unit-sequencer.test.mjs config/scripts/pr-workflow-parallelism.test.mjs --maxWorkers=2- passed: 83 tests in 6 files, including five draft/mode routing cases, warm/cold misses, provenance fallback and credential/error propagation.ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed --maxWorkers=2- passed all 14 checks after the final code edits and integration of current main, immediately before pushing658ea5275c2.actionlint -shellcheck= -ignore 'unexpected key "background"' -ignore 'step must run script with "run" section or run action with "uses" section' .github/workflows/unit-plan.yml .github/workflows/unit-tests.yml .github/workflows/unit-selection-evidence.yml .github/workflows/pr.yml- passed; ignores accommodate the repository's existing background/wait steps.git diff origin/main -- .github/workflows/unit-module-cache.yml .github/workflows/unit-module-cache-benchmark.yml- empty: neither producer nor benchmark behavior changes.Final full CI on
658ea5275c2- passed: all 12 full unit shards, Linux/Windows packaging, static/type checks, mobile/layout, dependency isolation, Git versions, shell, Codex, xterm, Node 18 and wire compatibility, plus the required aggregate gate. Planner: 8s, versus 64s in the reference; advisory evidence: 52s outside the gate. Headless routing and LoC also passed.Same-source experiment - passed all 36 shards with identical discovery/assignment/results/runtime/source checks and 12 valid warm hits. All 12 temporary comparison caches were individually identified and deleted. This validates the experiment, not an automatic production rollout.
Local platform: macOS ARM. Hosted checks cover Linux ARM/x64 and Windows. No application/UI behavior changed. Standalone local full lint/typecheck/test/build were not repeated; scoped local checks and full hosted gates cover the relevant changes.
Risk
Level: Medium
CI-only. Wrong matrix routing could omit tests; independent full discovery and provenance checks retain fail-closed fallback. Selected drafts retain their blocking plan. Advisory comparison remains outside the required aggregate gate. Cache identity, manifest validation, corrupt-cache fallback, save conditions and isolation are unchanged. Cache-producing workflows are unchanged, so there is no new cache growth or periodic producer cost to roll back. A plain revert restores prior orchestration. No application, SSH, mobile, workspace or persisted user-data behavior changes.
AI Disclosure
Review
Review found and resolved two issues: unbudgeted automatic cache generation, and duplicate dependency installation/graph work on selected draft PRs. No unresolved correctness finding remains in the retained diff. Final full hosted validation passed on the exact reviewed head
658ea5275c2.Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Cloned and inspected pinned Vitest v5.0.5 at
7a825db43e2beca0b219d2eadaec334cb81af0c7, including isolated worker lifecycle, persistent-cache invalidation and transform-service behavior. Review traced planning callers, per-shard discovery, fallback plans, advisory completeness, warm/cold writes, publishing conditions and producer lifetime. Runtime/UI performance is not affected.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)