From dcef20230c4daaae4013dc558351cb3acdb2eddd Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Sat, 14 Nov 2026 01:38:14 -0600 Subject: [PATCH 1/4] Dyno 11b: a page switch on the engine's loop stalls every mind's decode; the kv_page probe reads the engine's copy and IO apart The pinned fork runs a page save or restore, disk IO included, as one task on its single task loop: every other slot's decode waits for it, and switches issued together wait for each other (the M5 2026-11-14 00:18:13Z: Benchy's restore waited 1,024 ms behind Aris's 1,012 ms). Dyno 11b models the switch on the loop vs streamed (the loop copies the state in or out, the files move on a worker), from the restart day's receipts plus the M5's host memcpy (40,558,095 B/ms, measured 2026-11-14T07:24:45Z): - four residents' saves at once: decode stall 13,547 ms -> 204 ms; last receipt 13,547 ms -> 5,021 ms - the Aris/Benchy restore pair: Benchy's receipt 1,917 ms -> 1,026 ms; decode stall 1,917 ms -> 70 ms The kv_page.action probe reads the engine's receipt through one owner (EngineWork, in page_receipt.rs) and adds copy_ms (the engine loop's share, what other slots wait for) and io_ms (its IO worker's), "none" from an engine without them (fork PR #118). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- .../fixtures/dyno/2026-11-13-restart.json | 4 + core/continuum-engine/src/capacity/dyno.rs | 1 + .../src/capacity/dyno/restart.rs | 4 + .../src/capacity/dyno/restart/stall.rs | 154 ++++++++++++++++++ .../src/inference/turn_admission.rs | 15 +- .../inference/turn_admission/page_receipt.rs | 50 +++++- 6 files changed, 220 insertions(+), 8 deletions(-) create mode 100644 core/continuum-engine/src/capacity/dyno/restart/stall.rs diff --git a/core/continuum-engine/fixtures/dyno/2026-11-13-restart.json b/core/continuum-engine/fixtures/dyno/2026-11-13-restart.json index 8618ca732e..a4f6642ac2 100644 --- a/core/continuum-engine/fixtures/dyno/2026-11-13-restart.json +++ b/core/continuum-engine/fixtures/dyno/2026-11-13-restart.json @@ -36,5 +36,9 @@ "engine_page_lanes": { "value": 1, "receipt": "how many page saves/restores the pinned fork (cd2e16d87) runs at once: one. They are tasks on its single task loop (tools/server/server-queue.cpp:138-153 process_new_tasks; save at server-context.cpp:2809/2960, restore at 2996/3076). Measured: two restores the core issued at once after the 2026-11-14 00:18Z relaunch, Aris (00:18:13.016Z, ms=2573 engine_ms=1012 wait_ms=1561) and Benchy (00:18:13.925Z, ms=1930 engine_ms=906 wait_ms=1024): Benchy waited 1,024 ms, Aris's 1,012 ms in the engine" + }, + "host_copy_bytes_per_ms": { + "value": 40558095, + "receipt": "host memcpy on the M5 (Apple M5 Pro, Mac17,9) while it served its residents, 2026-11-14T07:24:45Z: 268,435,456 B copied (python3 bytes(bytearray), one memcpy) best of 7 in 6.62 ms. What the fork's loop pays per byte once a page switch only copies state in or out (llama_state_seq_get_data / set_data on unified memory); the deployed engine's own copy_ms receipt replaces it" } } diff --git a/core/continuum-engine/src/capacity/dyno.rs b/core/continuum-engine/src/capacity/dyno.rs index ed22ea39ed..0dd9cd3599 100644 --- a/core/continuum-engine/src/capacity/dyno.rs +++ b/core/continuum-engine/src/capacity/dyno.rs @@ -34,6 +34,7 @@ //! | 9 | boot during memory settle: a boot that remembered no resident launched at a reading taken while the stopped engine's memory came back (-c 2045, the M5 2026-11-13), and the grown plan was never applied | the boot's remembered residents -> `serving_daemon::launch::launch_pool`, `settle::launch_gate`, `floor_sized::floor_sized` | `continuum-serving` `serving_daemon/tests/dyno.rs` `boot_during_memory_settle` | //! | 10 | a leased-in mind sized from a prompt size, not her requirement | not drivable yet: [`expected::MissingSeam::LeasedInRequirement`] (the grid seam) | as 9 | //! | 11 | a restart re-prefills every mind (the M5 2026-11-13 23:45Z: the ledger restored nothing, every first act a full prefill), and the page store gave paged-out minds' pages to a volume other classes filled (29 in two hours) | the page store's `ColdPages::under` at the recorded pressure; save and restore costs from the engine's measured rates | `dyno/restart.rs` | +| 11b | a page switch holds the engine's one task loop for its disk IO: every slot's decode stalls for it and switches issued together wait for each other (the M5 2026-11-14 00:18:13Z: Benchy's restore waited 1,024 ms behind Aris's) | the engine's measured save/restore rates and the M5's host copy rate, the switch on the loop vs streamed (copy on the loop, IO on a worker) | `dyno/restart/stall.rs` | pub mod conservation; pub mod expected; diff --git a/core/continuum-engine/src/capacity/dyno/restart.rs b/core/continuum-engine/src/capacity/dyno/restart.rs index f48d52befc..d4c08f529b 100644 --- a/core/continuum-engine/src/capacity/dyno/restart.rs +++ b/core/continuum-engine/src/capacity/dyno/restart.rs @@ -10,6 +10,8 @@ use crate::inference::slots::{ColdPages, Ratio, StorePressure}; use super::recorded::Receipted; +mod stall; + /// The restart's data file, compiled in so a run needs no file system. const RESTART_JSON: &str = include_str!("../../../fixtures/dyno/2026-11-13-restart.json"); @@ -33,6 +35,8 @@ pub(crate) struct RestartDay { pub(crate) store_pressure: Receipted, /// How many page saves or restores the engine runs at once (the pinned fork: one). pub(crate) engine_page_lanes: Receipted, + /// What copying a page's bytes in host memory costs (dyno 11b, [`stall`]). + pub(crate) host_copy_bytes_per_ms: Receipted, } /// When each job completes, issued all at once in order onto `lanes` engine lanes, each diff --git a/core/continuum-engine/src/capacity/dyno/restart/stall.rs b/core/continuum-engine/src/capacity/dyno/restart/stall.rs new file mode 100644 index 0000000000..c0bbc8833a --- /dev/null +++ b/core/continuum-engine/src/capacity/dyno/restart/stall.rs @@ -0,0 +1,154 @@ +//! Dyno 11b: what a KV page switch costs the OTHER minds' decode. The pinned fork runs a whole +//! save or restore (the KV copy and the file IO) as one task on its single task loop, so every +//! slot's decode waits for it and switches issued together wait for each other (the M5 +//! 2026-11-14 00:18:13Z: Benchy's restore waited 1,024 ms, Aris's 1,012 ms in the engine). +//! Streamed, the loop only copies the sequence's state out (`llama_state_seq_get_data`) or in +//! (`set_data`), a memcpy proportional to the bytes; the file write or read runs on a worker per +//! switch and its completion is an event back to the loop. Rates are the restart day's +//! receipts ([`RestartDay`]); the copy rate is the M5's host memcpy until the deployed engine's +//! `copy_ms` receipt replaces it. + +use super::{completions, RestartDay}; + +/// Where the engine runs a page switch's work. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub(crate) enum PageIo { + /// The pinned fork: the whole switch is one task on the loop. + OnTheLoop, + /// The loop copies the state in or out; the file IO runs on a worker per switch. + Streamed, +} + +/// Which way a page moves. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub(crate) enum Way { + Save, + Restore, +} + +/// One switch the core issues: a mind's page of `tokens`, moving `way`. +#[derive(Debug, Clone, Copy)] +pub(crate) struct Switch { + pub(crate) way: Way, + pub(crate) tokens: u64, +} + +/// What a set of switches issued at once costs. +#[derive(Debug, Clone, PartialEq, Eq)] +pub(crate) struct Stall { + /// How long every slot not being switched cannot decode: the loop's time inside switches. + pub(crate) decode_stall_ms: u64, + /// When each switch's receipt is sent, from the issue, in the order issued. + pub(crate) done_ms: Vec, +} + +impl RestartDay { + /// The file IO of one switch at the engine's measured rate. The measured save rate includes + /// the copy the loop now does, so a streamed save's IO is over-counted by at most its copy. + fn io_ms(&self, s: Switch) -> u64 { + let rate = match s.way { + Way::Save => self.save_bytes_per_ms.value, + Way::Restore => self.restore_bytes_per_ms.value, + }; + self.page_bytes(s.tokens) / rate + } + + /// The loop's share of a streamed switch: its bytes at host memcpy, rounded up. The page's + /// bytes include its checkpoint sidecar; a restore only moves the sidecar's checkpoints into + /// the slot, so the restore's copy is an upper bound. + fn copy_ms(&self, s: Switch) -> u64 { + self.page_bytes(s.tokens).div_ceil(self.host_copy_bytes_per_ms.value) + } + + /// `switches` issued at once onto an engine that runs them `io`. Streamed, each switch has its + /// own worker (the fork sizes the pool from its slots); the loop takes the copy steps one at a + /// time: a save's at its issue, a restore's when its read completes. + pub(crate) fn switches_at_once(&self, switches: &[Switch], io: PageIo) -> Stall { + match io { + PageIo::OnTheLoop => { + let jobs: Vec = switches.iter().map(|s| self.io_ms(*s)).collect(); + Stall { decode_stall_ms: jobs.iter().sum(), done_ms: completions(&jobs, 1) } + } + PageIo::Streamed => { + let mut done_ms = vec![0u64; switches.len()]; + let mut loop_free = 0u64; + for (i, s) in switches.iter().enumerate().filter(|(_, s)| s.way == Way::Save) { + loop_free += self.copy_ms(*s); + done_ms[i] = loop_free + self.io_ms(*s); + } + let mut reads: Vec<(u64, usize)> = switches + .iter() + .enumerate() + .filter(|(_, s)| s.way == Way::Restore) + .map(|(i, s)| (self.io_ms(*s), i)) + .collect(); + reads.sort_unstable(); + for (read_done, i) in reads { + loop_free = loop_free.max(read_done) + self.copy_ms(switches[i]); + done_ms[i] = loop_free; + } + let decode_stall_ms = switches.iter().map(|s| self.copy_ms(*s)).sum(); + Stall { decode_stall_ms, done_ms } + } + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + fn day() -> RestartDay { + RestartDay::load().expect("test: the recorded 2026-11-13 restart data parses") + } + + fn saves(day: &RestartDay) -> Vec { + day.contexts_tokens.value.iter().map(|&tokens| Switch { way: Way::Save, tokens }).collect() + } + + // what this catches: a page save that holds the engine's loop for its disk write. The stop's + // checkpoint saves the four recorded residents at once: on the loop every other slot cannot + // decode for the ~13.5 s sum; streamed, the loop holds only the four copies (~0.2 s) and the + // last receipt arrives after the largest save plus the copies ahead of it (~5.0 s). + #[test] + fn four_saves_at_once_stall_decode_for_their_copies_not_their_writes() { + let day = day(); + let before = day.switches_at_once(&saves(&day), PageIo::OnTheLoop); + let after = day.switches_at_once(&saves(&day), PageIo::Streamed); + assert!((13_000..=14_000).contains(&before.decode_stall_ms), "{before:?}"); + assert!((150..=250).contains(&after.decode_stall_ms), "{after:?}"); + assert!(after.decode_stall_ms * 50 < before.decode_stall_ms, "streamed stalls decode under a fiftieth: {after:?} vs {before:?}"); + let last = after.done_ms.iter().max().copied().unwrap_or_default(); // unwrap_or_default: four saves were issued + assert!((4_900..=5_100).contains(&last), "the last receipt is the largest save plus the copies before it: {after:?}"); + assert!(last < before.done_ms.iter().max().copied().unwrap_or_default() / 2); // unwrap_or_default: as above + } + + // what this catches (the M5 2026-11-14 00:18:13Z): two restores issued together, the second + // waiting out the first in the engine (Benchy 1,024 ms behind Aris's 1,012 ms). Streamed, each + // mind waits for her own read and one set step (~1.0 s each), and the other slots' decode + // stalls ~70 ms instead of ~1.9 s. + #[test] + fn two_restores_issued_together_each_wait_only_for_their_own_read() { + let day = day(); + let pair = [Switch { way: Way::Restore, tokens: 43_389 }, Switch { way: Way::Restore, tokens: 43_637 }]; + let before = day.switches_at_once(&pair, PageIo::OnTheLoop); + let after = day.switches_at_once(&pair, PageIo::Streamed); + assert!((1_850..=1_950).contains(&before.done_ms[1]), "the second waits the first out: {before:?}"); + assert!(after.done_ms.iter().all(|ms| (950..=1_050).contains(ms)), "{after:?}"); + assert!((60..=80).contains(&after.decode_stall_ms), "{after:?}"); + assert!(after.decode_stall_ms * 20 < before.decode_stall_ms, "{after:?} vs {before:?}"); + } + + // what this catches: a streamed save's receipt counted before its file exists. A switch's + // receipt is never earlier than its own IO, whatever else is in flight. + #[test] + fn no_receipt_precedes_its_own_io() { + let day = day(); + let mut mixed = saves(&day); + mixed.push(Switch { way: Way::Restore, tokens: 43_389 }); + let after = day.switches_at_once(&mixed, PageIo::Streamed); + for (s, done) in mixed.iter().zip(&after.done_ms) { + assert!(*done >= day.io_ms(*s) + day.copy_ms(*s), "{s:?} done at {done} ms"); + } + } +} diff --git a/core/continuum-engine/src/inference/turn_admission.rs b/core/continuum-engine/src/inference/turn_admission.rs index 0e00f8d8cd..392091a599 100644 --- a/core/continuum-engine/src/inference/turn_admission.rs +++ b/core/continuum-engine/src/inference/turn_admission.rs @@ -43,7 +43,7 @@ pub use transient::admit_transient; use transient::admit_transient_through; pub(crate) use page_receipt::PageAction; -use page_receipt::{terminal_receipt, Terminal}; +use page_receipt::{terminal_receipt, EngineWork, Terminal}; use page_liveness::{bounded_page_receipt, wait_while_engine_progresses, PageLiveness, Receipt}; #[cfg(test)] use page_quote::read_quote; @@ -917,9 +917,7 @@ async fn kv_page_action_with_capacity( // its clock starts after a busy slot's deferral, so `ms - engine_ms` is the wait and // engine_ms the load (card a40e1bbf; the 5090 2026-10-11: Kimi's restores took 6-7.5 min // and nothing could say how much was waiting for the slot and how much was reading). - let (timing_field, bytes_field) = action.engine_fields(); - let engine_ms = body.as_ref().and_then(|b| b["timings"][timing_field].as_f64().map(|ms| ms as u64)); - let engine_bytes = body.as_ref().and_then(|b| b[bytes_field].as_u64()); + let work = EngineWork::of(action, body.as_ref()); let outcome = match terminal_receipt(action, slot, &filename, status, body.as_ref()) { Some(Terminal::Completed) => PageOutcome::Completed, Some(Terminal::Rejected) => PageOutcome::Rejected, @@ -968,11 +966,14 @@ async fn kv_page_action_with_capacity( status = status as u64, ms, // absent when the engine gave no timing (an older engine, or no terminal body) - engine_ms = %engine_ms.map_or_else(|| "none".to_string(), |v| v.to_string()), - wait_ms = %engine_ms.map_or_else(|| "none".to_string(), |v| ms.saturating_sub(v).to_string()), + engine_ms = %EngineWork::shown(work.ms), + wait_ms = %EngineWork::shown(work.ms.map(|v| ms.saturating_sub(v))), + // the engine's loop (what other slots' decode waits for) and its IO worker (fork #118) + copy_ms = %EngineWork::shown(work.copy_ms), + io_ms = %EngineWork::shown(work.io_ms), // the engine counts only the .bin; the sidecars (checkpoints, adapter vector) are read and // written in the same timed switch, so they are named apart (BigMama on #4957) - slot_bytes = %engine_bytes.map_or_else(|| "none".to_string(), |v| v.to_string()), + slot_bytes = %EngineWork::shown(work.bytes), sidecar_bytes = %crate::inference::slots::page_sidecar_bytes(&filename).map_or_else(|| "none".to_string(), |v| v.to_string()), bound_ms = bound.as_millis() as u64, node_p50_ms = p50_ms, diff --git a/core/continuum-engine/src/inference/turn_admission/page_receipt.rs b/core/continuum-engine/src/inference/turn_admission/page_receipt.rs index adbdffe6a2..191d9d17c8 100644 --- a/core/continuum-engine/src/inference/turn_admission/page_receipt.rs +++ b/core/continuum-engine/src/inference/turn_admission/page_receipt.rs @@ -25,7 +25,7 @@ impl PageAction { /// The fork's own timing and byte fields for this switch's work (`timings.save_ms`, /// `n_written` for a save; the read side for the rest). - pub(crate) fn engine_fields(self) -> (&'static str, &'static str) { + fn engine_fields(self) -> (&'static str, &'static str) { match self { Self::Save => ("save_ms", "n_written"), Self::Restore | Self::Erase => ("restore_ms", "n_read"), @@ -33,6 +33,38 @@ impl PageAction { } } +/// The engine's own account of a switch's work, each part absent when the engine gave none (an +/// older engine, or no terminal body). `ms` is its clock (it starts after a busy slot's deferral, +/// so the caller's elapsed minus `ms` is the wait); since fork #118 it splits into `copy_ms`, its +/// task loop's share (the state copied out or in: the only part other slots' decode waits for), +/// and `io_ms`, its IO worker's (the page files written or read, beside the decode). +#[derive(Debug, Clone, Copy, Default, PartialEq)] +pub(crate) struct EngineWork { + pub(crate) ms: Option, + pub(crate) bytes: Option, + pub(crate) copy_ms: Option, + pub(crate) io_ms: Option, +} + +impl EngineWork { + pub(crate) fn of(action: PageAction, body: Option<&serde_json::Value>) -> Self { + let Some(body) = body else { return Self::default() }; + let (timing, bytes) = action.engine_fields(); + let timings = &body["timings"]; + Self { + ms: timings[timing].as_f64().map(|ms| ms as u64), + bytes: body[bytes].as_u64(), + copy_ms: timings["copy_ms"].as_f64(), + io_ms: timings["io_ms"].as_f64(), + } + } + + /// A part as a probe shows it: its value, or "none" when the engine gave none. + pub(crate) fn shown(part: Option) -> String { + part.map_or_else(|| "none".to_string(), |v| v.to_string()) + } +} + /// What a terminal receipt proved the engine did. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub(crate) enum Terminal { @@ -87,6 +119,22 @@ mod tests { assert_eq!(terminal_receipt(PageAction::Erase, 3, "unused", 500, Some(&valid)), None); } + // what this catches: the engine's split of a switch (its loop's copy, its worker's IO, fork + // #118) unread, so a live read cannot tell whether a slow switch stalled the other minds' decode + // or only its own disk; an older engine's receipt reads as "none", never as zero. + #[test] + fn engine_work_reads_the_loop_and_io_shares_and_none_from_an_older_engine() { + let streamed = json!({"id_slot": 1, "filename": "p", "n_restored": 84, "n_read": 4096, + "timings": {"restore_ms": 1026.4, "copy_ms": 35.2, "io_ms": 991.2}}); + let work = EngineWork::of(PageAction::Restore, Some(&streamed)); + assert_eq!(work, EngineWork { ms: Some(1026), bytes: Some(4096), copy_ms: Some(35.2), io_ms: Some(991.2) }); + let older = json!({"id_slot": 1, "filename": "p", "n_saved": 84, "n_written": 4096, "timings": {"save_ms": 2253.0}}); + let work = EngineWork::of(PageAction::Save, Some(&older)); + assert_eq!((work.ms, work.copy_ms, work.io_ms), (Some(2253), None, None)); + assert_eq!(EngineWork::shown(work.copy_ms), "none"); + assert_eq!(EngineWork::of(PageAction::Save, None), EngineWork::default()); + } + #[test] fn erase_support_does_not_weaken_save_or_restore_receipts() { let erased = json!({"id_slot": 3, "n_erased": 10}); From ce440e896be42c4dd9d8337e2f723f62bd4deabc Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Sat, 14 Nov 2026 01:58:45 -0600 Subject: [PATCH 2/4] Dyno index: the 11b row is a doc comment Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- core/continuum-engine/src/capacity/dyno.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/continuum-engine/src/capacity/dyno.rs b/core/continuum-engine/src/capacity/dyno.rs index 0dd9cd3599..f8418cf70a 100644 --- a/core/continuum-engine/src/capacity/dyno.rs +++ b/core/continuum-engine/src/capacity/dyno.rs @@ -34,7 +34,7 @@ //! | 9 | boot during memory settle: a boot that remembered no resident launched at a reading taken while the stopped engine's memory came back (-c 2045, the M5 2026-11-13), and the grown plan was never applied | the boot's remembered residents -> `serving_daemon::launch::launch_pool`, `settle::launch_gate`, `floor_sized::floor_sized` | `continuum-serving` `serving_daemon/tests/dyno.rs` `boot_during_memory_settle` | //! | 10 | a leased-in mind sized from a prompt size, not her requirement | not drivable yet: [`expected::MissingSeam::LeasedInRequirement`] (the grid seam) | as 9 | //! | 11 | a restart re-prefills every mind (the M5 2026-11-13 23:45Z: the ledger restored nothing, every first act a full prefill), and the page store gave paged-out minds' pages to a volume other classes filled (29 in two hours) | the page store's `ColdPages::under` at the recorded pressure; save and restore costs from the engine's measured rates | `dyno/restart.rs` | -| 11b | a page switch holds the engine's one task loop for its disk IO: every slot's decode stalls for it and switches issued together wait for each other (the M5 2026-11-14 00:18:13Z: Benchy's restore waited 1,024 ms behind Aris's) | the engine's measured save/restore rates and the M5's host copy rate, the switch on the loop vs streamed (copy on the loop, IO on a worker) | `dyno/restart/stall.rs` | +//! | 11b | a page switch holds the engine's one task loop for its disk IO: every slot's decode stalls for it and switches issued together wait for each other (the M5 2026-11-14 00:18:13Z: Benchy's restore waited 1,024 ms behind Aris's) | the engine's measured save/restore rates and the M5's host copy rate, the switch on the loop vs streamed (copy on the loop, IO on a worker) | `dyno/restart/stall.rs` | pub mod conservation; pub mod expected; From d3f87b92782212b409af2c7e1f63740610396693 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Sat, 14 Nov 2026 07:25:37 -0600 Subject: [PATCH 3/4] The kv_page probe reads the engine's page IO budget: admit_ms and io_bytes_in_flight (fork #118 review) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- .../src/inference/turn_admission.rs | 2 ++ .../src/inference/turn_admission/page_receipt.rs | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/core/continuum-engine/src/inference/turn_admission.rs b/core/continuum-engine/src/inference/turn_admission.rs index 392091a599..6aab109425 100644 --- a/core/continuum-engine/src/inference/turn_admission.rs +++ b/core/continuum-engine/src/inference/turn_admission.rs @@ -971,6 +971,8 @@ async fn kv_page_action_with_capacity( // the engine's loop (what other slots' decode waits for) and its IO worker (fork #118) copy_ms = %EngineWork::shown(work.copy_ms), io_ms = %EngineWork::shown(work.io_ms), + admit_ms = %EngineWork::shown(work.admit_ms), + io_bytes_in_flight = %EngineWork::shown(work.in_flight_bytes), // the engine counts only the .bin; the sidecars (checkpoints, adapter vector) are read and // written in the same timed switch, so they are named apart (BigMama on #4957) slot_bytes = %EngineWork::shown(work.bytes), diff --git a/core/continuum-engine/src/inference/turn_admission/page_receipt.rs b/core/continuum-engine/src/inference/turn_admission/page_receipt.rs index 191d9d17c8..9da737ebb8 100644 --- a/core/continuum-engine/src/inference/turn_admission/page_receipt.rs +++ b/core/continuum-engine/src/inference/turn_admission/page_receipt.rs @@ -37,13 +37,16 @@ impl PageAction { /// older engine, or no terminal body). `ms` is its clock (it starts after a busy slot's deferral, /// so the caller's elapsed minus `ms` is the wait); since fork #118 it splits into `copy_ms`, its /// task loop's share (the state copied out or in: the only part other slots' decode waits for), -/// and `io_ms`, its IO worker's (the page files written or read, beside the decode). +/// and `io_ms`, its IO worker's (the page files written or read, beside the decode); `admit_ms` is +/// its wait for the engine's page IO byte budget and `in_flight_bytes` what every switch held then. #[derive(Debug, Clone, Copy, Default, PartialEq)] pub(crate) struct EngineWork { pub(crate) ms: Option, pub(crate) bytes: Option, pub(crate) copy_ms: Option, pub(crate) io_ms: Option, + pub(crate) admit_ms: Option, + pub(crate) in_flight_bytes: Option, } impl EngineWork { @@ -56,6 +59,8 @@ impl EngineWork { bytes: body[bytes].as_u64(), copy_ms: timings["copy_ms"].as_f64(), io_ms: timings["io_ms"].as_f64(), + admit_ms: timings["admit_ms"].as_f64(), + in_flight_bytes: body["page_io"]["io_bytes_in_flight"].as_u64(), } } @@ -125,12 +130,14 @@ mod tests { #[test] fn engine_work_reads_the_loop_and_io_shares_and_none_from_an_older_engine() { let streamed = json!({"id_slot": 1, "filename": "p", "n_restored": 84, "n_read": 4096, - "timings": {"restore_ms": 1026.4, "copy_ms": 35.2, "io_ms": 991.2}}); + "timings": {"restore_ms": 1026.4, "copy_ms": 35.2, "io_ms": 991.2, "admit_ms": 0.5}, + "page_io": {"io_bytes": 9000, "io_bytes_in_flight": 9000, "io_budget_bytes": 0}}); let work = EngineWork::of(PageAction::Restore, Some(&streamed)); - assert_eq!(work, EngineWork { ms: Some(1026), bytes: Some(4096), copy_ms: Some(35.2), io_ms: Some(991.2) }); + assert_eq!(work, EngineWork { ms: Some(1026), bytes: Some(4096), copy_ms: Some(35.2), io_ms: Some(991.2), + admit_ms: Some(0.5), in_flight_bytes: Some(9000) }); let older = json!({"id_slot": 1, "filename": "p", "n_saved": 84, "n_written": 4096, "timings": {"save_ms": 2253.0}}); let work = EngineWork::of(PageAction::Save, Some(&older)); - assert_eq!((work.ms, work.copy_ms, work.io_ms), (Some(2253), None, None)); + assert_eq!((work.ms, work.copy_ms, work.io_ms, work.in_flight_bytes), (Some(2253), None, None, None)); assert_eq!(EngineWork::shown(work.copy_ms), "none"); assert_eq!(EngineWork::of(PageAction::Save, None), EngineWork::default()); } From 3333695221893e98a4350c19823eb2b4be945cfb Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Sat, 14 Nov 2026 10:45:06 -0600 Subject: [PATCH 4/4] Engine pin -> fork 20b108f90 (#118 merged): page IO on its own worker with the in-flight byte budget Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- core/vendor/llama.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/vendor/llama.cpp b/core/vendor/llama.cpp index b5534b531f..20b108f906 160000 --- a/core/vendor/llama.cpp +++ b/core/vendor/llama.cpp @@ -1 +1 @@ -Subproject commit b5534b531f264fc8c05aee98f547a898ebe7e14d +Subproject commit 20b108f9068964cbca9302fb9cf2750d0122b9a7