diff --git a/crates/deploy/src/resources.rs b/crates/deploy/src/resources.rs index 747fbe94..fcfc2834 100644 --- a/crates/deploy/src/resources.rs +++ b/crates/deploy/src/resources.rs @@ -89,6 +89,10 @@ pub struct ResourcePlan { /// Windows file-backed form: GiB of experts the engine may page-lock, sized from the free RAM so that the desktop keeps its own working set /// (without it the engine takes nearly all free RAM; live native run 2026-10-25: 31 GiB resident, 14 GiB of swap, a refused start). pub resident_budget_gib: Option, + /// Windows file-backed form: lower memory-governor floors in MiB (soft, hard). Windows has no OOM killer and trims its standby list under + /// pressure, so the 4 GiB soft floor made for Linux only costs headroom: the engine's start check needs `fixed footprint + soft floor + reserve` + /// (29.4 + 4 + 1 GiB against 34 GiB available on the 48 GB laptop, live run 2026-10-25). + pub windows_floors_mib: Option<(u64, u64)>, /// Host RAM cannot hold the sealed archive and the experts next to the free target: serve from SSD/HDD instead /// (archive as a read-only file, experts memory-mapped, this many GiB of them page-locked). pub mapped_resident_gib: Option, @@ -133,6 +137,7 @@ pub fn compute(facts: &Facts, gpu: Option<&Gpu>, profile: &Profile, preset: Pres ram_expected_free_after_bytes: None, mapped_resident_gib: None, resident_budget_gib: None, + windows_floors_mib: None, problems: Vec::new(), warnings: Vec::new(), }; @@ -217,6 +222,7 @@ pub fn compute(facts: &Facts, gpu: Option<&Gpu>, profile: &Profile, preset: Pres { let room = ram.available.saturating_sub(WINDOWS_DESKTOP_RESERVE_BYTES + MAPPED_ENGINE_FIXED_BYTES) / GIB; plan.resident_budget_gib = Some(room.min(24) as u32); + plan.windows_floors_mib = Some((3072, 1536)); plan.warnings.push(format!( "Windows: the engine may page-lock {room} GiB of experts ({} available, {} left to the desktop, {} for the engine's own pools); close heavy applications for a larger share", gib_text(ram.available), @@ -256,6 +262,13 @@ pub fn apply( if let Some(resident) = plan.resident_budget_gib { profile.memory.resident_budget_gib.get_or_insert(resident); } + if let Some((soft, hard)) = plan.windows_floors_mib { + // only ever lowered, and only when the profile asks for more than the Windows values + if profile.memory.soft_floor_mib.is_none_or(|current| current > soft) { + profile.memory.soft_floor_mib = Some(soft); + profile.memory.hard_floor_mib = Some(hard); + } + } if let Some(workers) = plan.cpu_workers && !profile.engine_env.contains_key(CPU_WORKERS_ENV) { @@ -442,6 +455,7 @@ mod tests { let mut env = BTreeMap::new(); apply(&plan, &mut profile, &mut env, false); assert_eq!(profile.memory.resident_budget_gib, Some(11)); + assert_eq!((profile.memory.soft_floor_mib, profile.memory.hard_floor_mib), (Some(3072), Some(1536)), "Windows lowers the Linux floors of the laptop profile"); // an explicit profile value wins, and Linux hosts are left alone let mut explicit = laptop(); explicit.memory.resident_budget_gib = Some(16);