Skip to content

fix(deploy): a warm build yields the CPU to the serving core it runs beside - #4449

Merged
joelteply merged 1 commit into
canaryfrom
fix/a-warm-build-yields-the-cpu-to-serving
Sep 27, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/a-warm-build-yields-the-cpu-to-serving

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

A warm build compiles the next core while the current one keeps serving. It ran at normal priority, so on a CPU-served node the build and the lane competed as equals.

Measured on the IntelMac, 2026-09-27, from Cormac's read of the prompt captures:

  • A deploy build had been compiling for about 10 hours, holding load 25 on 12 cores.
  • 34 of 34 generations in one hour failed. 25 hit the 300 s header bound (a hung prefill) and 9 hit the 90 s no-progress bound.
  • The citizens took no turn all hour.

The fix: prepare_warm_build spawns the build at the lowest priority.

  • Unix: niceness 19, which cargo and every rustc inherit.
  • Windows: BELOW_NORMAL_PRIORITY_CLASS, which child processes inherit by default.

An idle machine still builds at full speed. A busy one hands its cores to serving. The deploy claim already renews while a build is alive (#4436), so a slower build is not mistaken for a dead one.

Test: a_warm_build_runs_at_the_lowest_priority_beside_the_serving_core spawns a child through yield_to_serving and asserts it reports niceness 19.

Not in this PR: continuum reboot stops the core before it builds, so it has nothing to contend with and is unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…beside

A warm build compiles the next core while the current one serves. It ran at
normal priority, so on a CPU-served node the build and the lane contended as
equals. On the IntelMac (2026-09-27) a ~10 h deploy build held load 25 on 12
cores, and Cormac's read of the prompt captures found 34 of 34 generations in
an hour failed: 25 at the 300 s header bound (hung prefill) and 9 at the 90 s
no-progress bound. The citizens took no turn all hour.

prepare_warm_build now spawns the build at the lowest priority: nice 19 on
Unix (inherited by cargo and every rustc), BELOW_NORMAL_PRIORITY_CLASS on
Windows (inherited by children by default). An idle machine builds at full
speed; a busy one hands its cores to serving.

Test: a child spawned through yield_to_serving reports niceness 19.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

Reviewed at de17a99 (Cormac). The code reads correct; my word is APPROVED once lib CI is green. I read the code and did not build it.

  • setpriority(PRIO_PROCESS, 0, 19) in pre_exec is async-signal-safe and inherited by cargo and rustc. The test observes nice = 19 in the child.
  • On Windows, creation_flags REPLACES rather than ORs, so I checked that nothing else sets a flag on the warm-build Command. It is built fresh at continuum.rs:2006, and apply_core_runtime_env sets none, so BELOW_NORMAL does not clobber a CREATE_NO_WINDOW. If one is ever added there, the two must be OR-ed; a line saying so at yield_to_serving would keep that from biting later.

Non-blocking:

  1. On macOS, nice 19 lowers CPU priority but not IO. A rustc link phase is IO-heavy, and the lane's model is mmapped. setpriority(PRIO_DARWIN_PROCESS, 0, PRIO_DARWIN_BG) would also throttle IO and put the build on the E-cores on Apple silicon. It is worth measuring on the M5 before adding.
  2. The setpriority result is dropped. A failure (it should not happen, since lowering needs no privilege) would silently build at normal priority. A probe on nonzero would make that visible.
  3. Expect the IntelMac build to run LONGER now under a busy lane. That is the intended trade, and renewal (fix(deploy): a live deploy's claim renews while it builds, and expires on silence, not age (card 2b226917) #4436) makes it safe.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

@joelteply

Copy link
Copy Markdown
Contributor Author

APPROVED at de17a99 (Cormac), with CI 8/8 green. The review above stands, and its notes are non-blocking.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

@joelteply
joelteply merged commit da0ff14 into canary Sep 27, 2026
8 checks passed
@joelteply
joelteply deleted the fix/a-warm-build-yields-the-cpu-to-serving branch September 27, 2026 06:33
joelteply added a commit that referenced this pull request Sep 27, 2026
…ld installs the pinned llama-server on macOS/Linux, and a lane on an older engine than the installed one is relaunched (card 7c5f139d) (#4464)

* fix(serving,deploy): a deploy converges the ENGINE too — the warm build installs the pinned llama-server on macOS/Linux, and a lane on an older engine than the installed one is relaunched (card 7c5f139d)

The M5 and the IntelMac served llama-server b10765-965d38a90 (no /train) a day after the pin
reached 9733aca6c, so the M5 could not dream whatever S3-S5 landed. Two holes:
1. Build: a deploy's warm build runs start-server.sh with BUILD_ONLY=1, and the engine install
   sits in the runtime-only branch, so a Mac deploy never built the engine. `continuum install`
   has an engine arm only on Windows (#4382).
2. Adopt: every deploy leaves the lane up for the next core, and adoption asked only window,
   lanes, sight and KV. An adopted lane kept running the binary it was launched from.

Now:
- start-server.sh, BUILD_ONLY on Darwin/Linux (not under an LLAMA_SERVER_BIN override): run
  install-llama-server.sh in the warm pass. It is stamp-gated (instant when commit:backend
  match) and installs atomically (rm, temp, codesign, mv), so a running lane keeps its old
  inode; the engine is static on macOS (otool: libSystem, Accelerate, libc++). It inherits
  nice 19 (#4449). A failed build warns and never fails the core deploy; the stamp is written
  only after a verified build, so the lane keeps the engine it has.
- llama_server: a fourth adopt-or-relaunch operand, asked of the lane like the other three.
  `/props` build_info (the IntelMac lane: "b10765-965d38a90") against the installed stamp
  (`.llama-server.stamp` beside the resolved server_bin: "965d38a90:cpu"). If they disagree,
  the lane is relaunched onto the installed binary, at the same size; the trade guard and the
  memory gate do not apply, since it is not a resize. Unknown on either side (a probe error, no
  field, an operator override, no stamp) is "engine OK": never a spurious relaunch.
- Probe: serving.engine.converged {from, to}.
- Windows: the core launches with LLAMA_SERVER_BIN at the registered engine slot, and the stamp
  lives in that slot, so the same comparison converges a lane onto a newly registered engine
  after an install. No platform code.

Test (llama_server, existing mod): an older engine is stale; the same commit short or full is
current; no build or no stamp never relaunches.

Not compiled on the IntelMac: its deploy build holds the machine. CI is the compile.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* fix(serving): the engine comparison uses deploy_provenance::sha_matches, and the hour's health line carries engine_stale (BigMama on 7c5f139d)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* fix(serving): an engine relaunch happens once per from->to, and a lane that still reports the old build after it is reported, never relaunched again (Fable on #4464)

A relaunched lane whose build_info was not regenerated (a local merge, a gitdir-file submodule)
would otherwise relaunch onto the same binary every tick: a dark lane on a loop. The second
sighting of the same pair probes serving.engine.converge_failed and leaves engine_stale on the
health line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* test(deploy): a warm build runs the engine install on macOS/Linux, once, and its failure never fails the deploy (card 7c5f139d)

start-server-build-only.test.sh forbade install-llama-server.sh in every warm
build, the invariant this PR deliberately changes. The stub now records the
call: exactly one on a successful macOS/Linux warm build, none on Windows
(#4382) and none after a failed core build (which exits first). One more case:
a failing engine build still completes the warm build with the warning and a
receipt. Mutation: dropping Linux from the case arm fails the test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant