Skip to content

perf(ci): consolidate workers, eliminate redundant builds, and tighten scoping - #7013

Merged
Astro-Han merged 7 commits into
rust-previewfrom
perf/ci-reduce-jobs-and-compile-overhead
Nov 19, 2026
Merged

Astro-Han merged 7 commits into
rust-previewfrom
perf/ci-reduce-jobs-and-compile-overhead

Conversation

@Astro-Han

@Astro-Han Astro-Han commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Recent rust-preview CI runs spawned up to 35 jobs (~492 runner-minutes total, ~195m wall clock), frequently timing out native-macos at 180m and failing native-windows at 150-177m. Profiling hosted runs showed four compounding bottlenecks rather than excessive test volume:

  • Over-sharding and setup overhead: root-tests spawned 22 Ubuntu runners (many running 30-120s of tests after 10-18m of ASF queue wait), each installing build-time -dev packages and running npm install -g npm@latest + npm ci even when replay never compiles or touches node_modules.
  • Cache eviction spiral & per-worker recompilation: Separate Linux per-role caches consumed ~11.9 GiB and individual macOS/Windows caches reached 4.6-5.2 GiB against the 10 GiB Actions cache limit because each worker invoked cargo 5-6 times with different -p sets (triggering repeated Cargo feature unification rebuilds), evicting caches to 0 and forcing 100-129m cold builds.
  • Platform & tooling drag: CARGO_BUILD_JOBS=2 throttled compilation, Linux linked with default GNU ld, Windows Defender scanned target/, prune cleaned untouched vendored third-party/* crates on every run, verifyRoot round-tripped local binaries through .tar.zst archives, and native-macos/native-windows ran their slowest E2E suites serially on one runner.
  • Over-broad input scoping: Non-Rust workbench/plugin/skill edits fell back to root all() and triggered unrelated backend/platform suites, and branch pushes always re-ran untouched vendored third-party/nsh and third-party/termina.

This PR keeps the full test coverage intact while eliminating that waste:

  • Consolidate root-tests from 22 to 6 balanced partitions (native: 3, cli: 2, rest: 1), upload 3 archives instead of 6, switch replay setup to runtime-only Linux packages (dependencies: replay), and keep javascript: true only for the rest partition where maka-workbench tests load node_modules.
  • Consolidate Linux workers, use lld, and protect the cache pool: merge contracts, product, native-build, native, linux-desktop, and bridge into linux-checks (restoring the root compiler cache read-only via cache_role: root + saveCache: false, and using cargo build --locked --workspace --bin maka so Linux native reuses 1,504/1,505 root-build .rlib units instead of recompiling 1,061 cargo check units), merge nsh + linux-nsh into nsh, link Linux CI builds with clang + -fuse-ld=lld, align CARGO_PROFILE_{DEV,TEST}_DEBUG=0 and CARGO_PROFILE_{DEV,TEST}_BUILD_OVERRIDE_DEBUG=0 across CI, and drop CARGO_BUILD_JOBS=2.
  • Eliminate repeated dependency compilation & preserve third-party/ cache reuse: add unified cargoScope package sets with per-suite targetArgs dynamically unioned across selected suites so native-macos and native-windows compile once per worker (and only save shared exact caches when all suites on the worker are selected), include HEAD:third-party tree SHA in exact compiled cache keys while keeping compiled_prefix free of thirdPartyTree (stabilizing mtimes on exact hits and running clean-third-party on fallback restores so untouched registry crates survive third-party/ edits), stage prebuilt librusty_v8 into both target/debug/gn_out/obj and target/debug/build/gn_out/obj for Cargo 1.100, and exclude target/ + ~/.cargo from Windows Defender.
  • Parallelize heavy native E2E & split vendored NSH: run local helper-backed suites directly via cargo nextest run with a single workspace-scoped helper build forwarding local Cargo flags (--features, --config, --offline, --frozen, --release, --target*, --cargo-profile), resolve ui_types from Cargo JSON artifacts, split macos-nsh (including nsh-cli) and windows-nsh into independent on-demand workers, split macOS into parallel native-macos + native-macos-agent (read-only shared cache), and split Windows desktop E2E into parallel count:1/2 + count:2/2 (read-only shared cache).
  • Tighten change planning safely: preserve Rust crate ownership for non-Rust fixtures inside backend crates, exclude /src/ template READMEs from documentation filtering, keep bundled non-workbench product inputs on macos-agent-execution, map shared product contract directories (bundle, plugin-sdk, plugins/shared, gateway) to their full backend/skill consumers while keeping pure workbench UI edits scoped to UI/product crates, and skip untouched vendored third-party/nsh and third-party/termina on branch pushes while keeping full root coverage.

Benchmark Progression & Evidence

All hosted metrics below are taken directly from GitHub Actions runs on apache/maka.

Stage Run Cache State Jobs Wall Clock Total Exec root-build linux-checks native-macos native-macos-agent native-windows native-windows-desktop-2
Baseline (rust-preview) #44342177411 Cold (evicted) 35 195.2m 491.7m 37.9m — (5 jobs) 180.2m (timeout) — (serial) 149.9m — (serial)
Round 1 (consolidate + DEBUG=0 + drop JOBS=2) #44445113369 Cold 17 93.5m (-52%) 313.3m (-36%) 21.8m 39.1m 90.1m — 81.3m —
Round 2 (unified cargoScope + Defender + V8 dual-stage) #44457489955 Cold (superseded) 17 — — 19.8m 29.0m compile 31.6m — compile 32.5m —
Round 3 (clang+lld + third-party cache + native splits) #44461428936 Cold 19 61.8m (-68%) 344.6m (-30%) 19.7m 34.3m 60.5m 50.1m 45.3m 51.3m
Round 4 (explicit saveCache + BUILD_OVERRIDE_DEBUG=0) #44475727934 Cold 19 54.0m (-72%) 319.6m (-35%) 22.7m 35.3m 37.2m 43.0m 39.5m 52.5m
Final PR run (review fixes + clean-third-party fallback) #44492026748 Fallback (+18–33m queue) 19 81.0m 354.4m 23.2m 38.9m 48.5m 42.1m 59.8m 43.1m
Post-merge rust-preview base run #44515944546 Cold (seeds base cache) 19 68.3m 379.4m 23.7m 35.6m 64.1m 45.0m 53.7m 50.9m
Post-merge downstream PR (untouched NSH/termina skipped) #44527452235 Warm/fallback 14 (-60%) — — 16.6m (-56%) in progress in progress in progress in progress in progress

Key per-optimization measurements:

  • Unified per-worker cargoScope + DEBUG=0 + Defender exclusion: cut native-macos cold compile from 124m → 31.6m (-75%) and native-windows cold compile from 106m → 32.5m (-69%) (measured in #44457489955).
  • Parallel native E2E splits: cut native-macos verify from 27–51m to ~15m alongside native-macos-agent (verify 9.9–12.9m, total 37.1m green on post-merge rust-preview #44523459467), and split Windows desktop E2E into two ~6–9m verify shards (both green in #44475727934, #44492026748, and #44515944546).
  • CARGO_PROFILE_{DEV,TEST}_BUILD_OVERRIDE_DEBUG=0: shrank the saved root-build compiler cache from 2.31 GiB → 1.75 GiB (-24%) in #44475727934.
  • Linux native cache alignment (cargo build vs cargo check): Cargo --unit-graph under CI profile env vars confirmed cargo check --locked --workspace --bin maka missed 1,061 / 2,257 external units against root-build, whereas cargo build --locked --workspace --bin maka reuses 1,504 / 1,505 (99.93%) external units.
  • root-tests consolidation (22 → 6) + dependencies: replay + selective JS: all 6 partitions ran cleanly in 3–14m each (rest executed 895 tests in 3.1–7.2m).
  • On-demand NSH workers & fullRoot vendored scoping: macos-nsh dropped to 5.3–5.8m on warm cache (#44457489955, #44482637336); non-vendored PRs and rust-preview pushes (#44527452235, #44523459467) automatically skip all 4 vendored NSH/termina jobs (14 jobs total vs 35 baseline).
  • Attribution of the 2 failing tests in final PR run #44492026748: 16/18 execution jobs passed; desktop_composer_references_a_room_without_posting on native-macos reproduced identically on baseline rust-preview #44476602729, and continue_run_recovers_across_interrupted_boundaries hit a single Elapsed timeout flake (passed in rounds 1–4).

Verification

  • node --test scripts/ci.test.mjs — 22/22 passed.
  • biome format . and node scripts/asf-license-headers.mjs check — passed.
  • Verified against live workspace cargo metadata and Cargo --unit-graph for scoped native worker target unions, Linux cargo build vs cargo check unit reuse, backend fixture & plugin routing, local helper flag forwarding, archive() fallback helper builds, narrow-PR saveCache: false guards, and clean-third-party fallback cleanup.

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Google Antigravity profiled hosted CI runs and implemented the workflow and scripts/ci/* changes; GPT 6.2 Sol performed three rounds of independent adversarial reviews whose verified findings were addressed in this branch.

Checklist

  • Tests cover the change and fail without it
  • Format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

…n scoping

Reduce CI job count, queue pressure, cache eviction, and compilation time on rust-preview without reducing test coverage:

- Consolidate root-tests sharding from 22 partitions (8 native, 6 cli, 8 rest-1..4) to 6 balanced partitions (3 native, 2 cli, 1 rest) and switch replay jobs to lightweight runtime-only Linux packages without npm install.
- Merge Linux root verification workers (contracts, product, native-build, native, linux-desktop, bridge) into a single linux-checks worker that restores the root compiler cache read-only, and merge nsh + linux-nsh into one nsh worker so Linux caches stop evicting macOS and Windows caches past the 10 GiB limit.
- Set CARGO_PROFILE_DEV_DEBUG=0 and CARGO_PROFILE_TEST_DEBUG=0 across CI jobs and remove the artificial CARGO_BUILD_JOBS=2 throttle.
- Replace --workspace test compilation on native-macos and native-windows with targeted package/binary Cargo arguments, drop redundant --no-default-features helper builds, split macos-nsh and windows-nsh into independent on-demand workers, and run local helper-backed nextest suites directly instead of round-tripping through .tar.zst archives.
- Scope non-Rust product, skill, and external fixture inputs in plan.mjs to their actual consumer packages instead of falling back to all(), and skip untouched vendored third-party workspaces on branch pushes while keeping full root coverage.

Generated-by: Google Antigravity
…est replay

Eliminate repeated dependency recompilation inside native-macos, native-windows, and linux-checks, and fix the two issues surfaced in the first hosted run:

- Add unified cargoScope package sets to native-macos and native-windows so prepareWorker compiles all needed crates once under a single Cargo feature union (and builds runtime helpers in the same union), cutting redundant dependency rebuilds and shrinking per-worker caches well below the 10 GiB cap.
- Align linux-checks heavy Rust targets (ui_types, linux-desktop, Linux native check) with the --workspace feature union so they reuse the root compiler cache.
- Exclude target/ and ~/.cargo from Windows Defender real-time scanning in ci-setup on Windows runners.
- Stage prebuilt librusty_v8 into both target/debug/gn_out/obj and target/debug/build/gn_out/obj to match Cargo 1.100 OUT_DIR nesting and prevent concurrent v8 build.rs truncation.
- Enable javascript setup only for the rest partition in root-tests where maka-workbench tests load node_modules at runtime, while keeping native and cli partitions npm-free.

Generated-by: Google Antigravity
@github-actions github-actions Bot added the effort/XL Under 2500 readable lines label Nov 19, 2026
… macOS/Windows E2E

Push CI latency further without reducing test coverage:

- Install lld on Linux compile workers and link x86_64-unknown-linux-gnu targets with clang + -fuse-ld=lld.
- Include HEAD:third-party tree SHA in root compiler cache keys, keep vendored third-party/* path crate outputs during cache prune, and stabilize third-party/ mtimes on exact cache hits so unchanged nsh/reqwest/sqlx/deno crates stay Fresh across runs.
- Split macOS E2E into parallel native-macos (desktop + platform suites) and native-macos-agent (macos-agent-execution, read-only shared cache), and split Windows desktop E2E into parallel count:1/2 and count:2/2 workers (read-only shared cache).
- Fix contracts verification by invoking the compiled target/debug/examples/ui_types binary directly instead of passing --workspace to cargo run.

Generated-by: Google Antigravity
GitHub Actions evaluates null != false as false, which caused cache-owning workers without an explicit saveCache field to skip ci-cache.

Generated-by: Google Antigravity
…, and local runs

Address all verified findings from adversarial review:

- Keep non-Rust fixtures inside backend Rust crates (e.g. maka-decisions-api) routed through their owning crate, and route shared product contract directories (bundle, plugin-sdk, plugins/shared, gateway) to maka-agent-native, maka-skills-core, maka-skills-native, macos-agent-execution, and windows-skills while keeping pure UI edits scoped.
- Add nsh-cli to macos-nsh suite packages so changes to nsh-cli/src/test.rs trigger macos-nsh on branch pushes.
- Include HEAD:third-party tree SHA in compiled_prefix so fallback cache restores never mix vendored outputs across different third-party trees.
- Align CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=0 and CARGO_PROFILE_TEST_BUILD_OVERRIDE_DEBUG=0 with dev/test profiles to prevent compiling shared build/normal deps (maka-ui-build) twice.
- Resolve ui_types example executable from Cargo JSON output in contracts verification instead of hardcoding target/debug/examples/ui_types.
- Forward local Cargo build flags (--release, --cargo-profile, --target, --target-dir, features) into buildRuntimeHelpers and skip helper builds on --help/-h/--no-run.
- Add targeted prepareTargets for sidecar parallel shards (native-macos-agent, native-windows-desktop-2) so they reuse the primary cargoScope dependency graph without linking unrelated test binaries.

Generated-by: Google Antigravity
…ache fallback

- Restore bundled non-workbench product inputs on macos-agent-execution so plugin edits still run macOS agent reopen tests.
- Build local runtime helpers in a single workspace-scoped cargo build so qualified --features flags work with just test.
- Exclude src/ template README files from documentation filtering in plan.mjs.
- Replace worker prepareTargets with per-suite targetArgs unioned dynamically across selected suites.
- Keep thirdPartyTree in exact compiled cache keys only and clean third-party path crates on fallback restores so registry caches survive third-party edits.

Generated-by: Google Antigravity
…reuse, and local flags

- Remove stale artifact.cargoArgs spread in prepareRuntimeHelpers that broke root-build archive creation.
- Prevent scoped native PR workers from overwriting shared exact compiler caches when only a subset of suites is selected.
- Use cargo build instead of cargo check for Linux native suite under cacheRole=root so it reuses root-build .rlib outputs.
- Forward --config, --offline, and --frozen to local runtime helper builds.

Generated-by: Google Antigravity
@Astro-Han
Astro-Han marked this pull request as ready for review November 19, 2026 10:42
@Astro-Han
Astro-Han merged commit a4d18f3 into rust-preview Nov 19, 2026
16 of 19 checks passed
@Astro-Han
Astro-Han deleted the perf/ci-reduce-jobs-and-compile-overhead branch November 19, 2026 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/XL Under 2500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant