Skip to content

ci: reduce cold builds and unnecessary runner work - #941

Merged
Tryanks merged 15 commits into
mainfrom
ci/reduce-runner-time
Oct 24, 2026
Merged

Tryanks merged 15 commits into
mainfrom
ci/reduce-runner-time

Conversation

@Tryanks

@Tryanks Tryanks commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

Cut wasted runner time while keeping every platform, check and assertion. Final head d54e1ae9 passed all checks in 9m51s with zero LEAK on every runner, Windows included at eight test slots. The ~5-minute target is not met; see Merge Danger.

 CI, per push
-  desktop matrix of platform × {clippy, tests}; three gates, each waiting for all six jobs
+  <platform> / clippy and <platform> / tests; each required platform check waits for its own two
-  Clippy saves its own cache per platform
+  Clippy restores the test cache and saves none
-  release jobs save tag-scoped Cargo caches
+  release jobs save none
-  Linux installs GTK/WebKit (the glib-sys probe exits 0 when it prints nothing) from the Azure mirror
+  Linux installs only the packages the build and tests use, from the official HTTPS archive
-  LEAK fails only under --profile ci; Windows runs CPU × 1 slots
+  LEAK fails in nextest's default profile; every runner runs CPU × 2 slots
+  the slow syntax regression starts first and compiles each distinct pattern once

The Windows leaks were Tcode's: a Windows child inherits every inheritable handle of its parent, so a git that outlived a test process held nextest's output pipes open. Both process helpers now take Tcode's own standard handles out of that set once; Stdio::inherit still hands them over through std's inheritable duplicates.

 services::process::command / agent's process::command
+  agent::keep_own_stdio_from_children()   # Windows: clear HANDLE_FLAG_INHERIT on stdin/stdout/stderr, once
   CREATE_NO_WINDOW, PATHEXT resolution

The runtime test host no longer guesses how long background work takes:

 TestAppContext::run_until_parked
-  wait out a 50/250 ms quiet window after the last message
+  run what is queued and what it queues, barrier the store writer, return
 a test that needs background work's result
+  run_until(the state it asserts)

One repository lookup reads the remotes once, through the one trait method that takes it:

 trait Forge
-  fn checkout_repository(&self, cwd: &Path)            # forwarded to resolve_checkout
-  fn resolve_checkout(&self, checkout: &Checkout)
-  fn discover(&self, cwd: &Path, root: &Path, refresh)
+  fn checkout_repository(&self, checkout: &Checkout)
+  fn discover(&self, cwd: &Path, root: &Checkout, refresh)   # routing and the chosen host share the listing

A branch checked out at the root reuses the root's listing; branch_head and read_status read theirs once; GitHub maps remotes through the shared parser.

Evidence

Before: head f06d3ab5, run 40013348040, 10m03s. A Windows-only failure (runs 40003709717, 40006676143) failed the required Linux x64 check and cancelled Windows x64 and macOS arm64. Eight Windows slots produced 29 and 28 LEAKs in a same-binary comparison.

After: head d54e1ae9, run 40039230438, attempt 1, 9m51s, every job passed:

Tests job Slots Cache Build Test execution Done Result
Linux 8 34s 1m15s 93.3s (was 171.1s) 4m04s 1261 passed, 0 LEAK
macOS 6 37s 4m06s 157.1s (was 157.9s) 8m15s 1276 passed, 0 LEAK
Windows 8 (was 4) 71s 4m13s 151.4s (was 199.7s) 9m46s 1231 passed, 0 LEAK
  • Each platform check finished right after its own jobs: Linux +4m08s, macOS +8m21s, Windows +9m51s.
  • Clippy, restoring the test cache instead of starting cold, finished at 1m58s / 2m14s / 4m32s after the run started (was 3m50s / 5m41s / 5m09s) for Linux / macOS / Windows.
  • Linux apt: 19s and 20s. On the old workflow, 3 of 16 recent runs spent 1480–1921s in apt; the other 13 took 27–49s.

Local, macOS, through mbx:

  • cargo fmt --all --check, cargo clippy --workspace --all-targets --locked -- -D warnings, actionlint: clean.
  • cargo nextest run --workspace --locked with LEAK failing: 1269 passed, 13 skipped.
  • tcode-runtime at 30 slots on 15 CPUs, with 15 busy loops saturating the CPU: 20 of 20 stress iterations passed.
  • The new keep_own_stdio_from_children type-checks and passes Clippy for x86_64-pc-windows-msvc; Windows CI ran it.

Tests that relied on the quiet window, found by running the runtime suite with no window under load. Each now waits for the state it asserts; a state never reached fails after five seconds, and no assertion was loosened:

  • sweep helper: a sweep that finds a sync running is skipped, so it lets that sync finish first (an_ended_rebase_is_kept_for_every_device_until_the_next_full_sync_and_blocks_no_write failed every loaded run).
  • a_finished_child_holds_its_lead_until_settled_and_cancel_never_delivers: waits for the Cancel reply.
  • pages_and_outputs_of_a_thread_nobody_opened_are_read_and_not_kept, an_appended_snapshot_drops_the_superseded_ones_diffs_in_the_same_commit: the bounded read answers before the whole-log read finishes; they wait for that read, then assert nothing or the whole log is kept.
  • instructions_reach_the_provider_at_launch_and_no_turn_carries_them, a_wake_steers_into_a_running_turn_and_is_not_repeated, the watch harness's accept: wait for the host to take the provider's events.
  • native mirror lifecycle helper: waits for the last reply as well as the turn's end.

Merge Danger

Door: two-way

Blast Radius: CI, the runtime test host, repository discovery

  • Every Windows process that spawns a child clears the inherit flag on its own standard handles once. Children built by std still receive what they ask for; portable-pty already spawns without inheritance.
  • A runtime test that needs background work without waiting for its state now fails instead of passing by timing.
  • Each run starts three macOS jobs instead of two; the account allows five concurrently, so overlapping runs can queue.
  • Docker images and Compose template (#811); machine groups (#935) #888's release workflow still saves tag-scoped Rust and buildx caches; it is to be optimized when rebased onto this.
  • The ~5-minute target is not met. The critical path is the Windows test job: 71s cache restore, 4m13s build, 2m31s test execution.
  • Open: one failure of interrupt_pauses_an_idle_watch_and_resume_catches_up_once_after_restart ("expected a delivered turn") in about 60 runtime-suite runs at roughly 7× CPU oversubscription; not reproduced in 30 targeted runs, at 2×, or in CI.

A Windows child inherits every inheritable handle of its parent, so a git
that outlived a test process held nextest's output pipes open and the test
was reported as leaky. The process helpers now take tcode's standard handles
out of that set once; Stdio::inherit still hands them over through std's own
inheritable duplicates.
run_until_parked waited out a 50/250 ms quiet window: a guess at how long
background work takes, which loaded runners overrun. It now runs what is
queued, barriers the store writer and returns. The tests that relied on the
window wait for the state they assert instead:

- sweep lets a running sync finish, since a sweep that finds one is skipped
- an orchestration Cancel waits for its reply
- a cold read and a subscription wait for the whole log after the bounded
  read answers first
- provider events wait for the host to take or act on them
- the native mirror waits for its last reply as well as its turn end
The Forge trait takes the lookup itself: checkout_repository and discover
receive a Checkout, so routing through the hosts and the chosen host's
discovery read the remotes once, and the second trait method that only
forwarded to the first is gone. A branch checked out at the project root
reuses the root's listing, branch_head and read_status read theirs once, and
GitHub maps remotes through the shared parser instead of a copy of it.
- Each platform's Clippy and tests are two jobs, and its required check
  waits for those two alone, so a failure names the platform it happened on
  instead of failing one gate and cancelling the others.
- Clippy restores the test cache instead of saving a cache of its own.
- Leaked output handles fail in the default nextest profile, so the
  documented local command and CI judge them the same way.
- Windows uses two test slots per CPU like the other runners, now that
  children no longer inherit the test process's output pipes.
@Tryanks
Tryanks merged commit b6bf115 into main Oct 24, 2026
13 checks passed
@Tryanks
Tryanks deleted the ci/reduce-runner-time branch October 24, 2026 05:15
Tryanks added a commit that referenced this pull request Oct 24, 2026
#962)

GitHub creates a job that waits on others only once they finish. Since #941
CI's required platform checks are such jobs, so for minutes at a time the
head showed every required check reported so far as passed while macOS arm64
and Windows x64 did not exist yet, and the watch woke the agent mid-run.

When the checks read would pass, the GitHub detail read now adds the checks
the base branch requires but that have not reported, as pending: those of its
rulesets come with the GraphQL detail, those of its branch protection from
REST, which any reader may see (GraphQL shows them to admins alone). Core
owns the gate both use.
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.

1 participant