From 8519680df0b6f403b03e82752ffcb90b4643bb73 Mon Sep 17 00:00:00 2001 From: Harrison Booth <73434116+Harrison-Booth@users.noreply.github.com> Date: Mon, 26 Oct 2026 13:08:52 -0500 Subject: [PATCH 1/7] Soak tests: fail on resident memory growth after warm-up --- crates/engine/src/soak_tests.rs | 24 +++++++++++++++++++++++- crates/ui-egui/src/ui_soak_tests.rs | 21 +++++++++++++++++++++ docs/gaps.md | 10 ++++++---- 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/soak_tests.rs b/crates/engine/src/soak_tests.rs index 2b3154053..25f43f115 100644 --- a/crates/engine/src/soak_tests.rs +++ b/crates/engine/src/soak_tests.rs @@ -64,6 +64,17 @@ fn params(r: &mut Rng, s: &Session) -> Value { } } +/// Resident set size in bytes, where `/proc` exists; other platforms are not sampled. +/// shortcut: assumes 4 KiB pages, upgrade when a 16 KiB-page target runs the soak. +fn rss_bytes() -> Option { + let statm = std::fs::read_to_string("/proc/self/statm").ok()?; + Some(statm.split_whitespace().nth(1)?.parse::().ok()? * 4096) +} + +/// RSS growth allowed between the warmed-up start and the end of a soak. Generous: `cargo test` +/// threads share the process, so other tests' allocations count too. +const MAX_RSS_GROWTH: u64 = 256 << 20; + fn doc(s: &Session) -> Option { s.active().map(|d| (*d.doc).clone()) } @@ -91,7 +102,12 @@ fn soak(seed: u64, steps: usize) { let mut r = Rng(seed | 1); let mut log: VecDeque = VecDeque::new(); let mut edits = 0usize; + let mut rss_start = None; for step in 0..steps { + // Sample after a quarter of the run so one-off caches and allocator arenas are warm. + if step == steps / 4 { + rss_start = rss_bytes(); + } let id = *r.pick(&ids).unwrap(); let p = params(&mut r, &s); log.push_back(format!("{id} {p}")); @@ -140,7 +156,13 @@ fn soak(seed: u64, steps: usize) { } // The soak must really edit, not just bounce off disabled commands. assert!(edits * 10 >= steps, "only {edits} of {steps} steps changed the document; seed {seed}"); - eprintln!("soak seed {seed}: {edits} of {steps} steps edited"); + if let (Some(start), Some(end)) = (rss_start, rss_bytes()) { + let grew = end.saturating_sub(start); + eprintln!("soak seed {seed}: {edits} of {steps} steps edited, RSS {} -> {} MiB", start >> 20, end >> 20); + assert!(grew <= MAX_RSS_GROWTH, "RSS grew {} MiB over {} MiB; seed {seed}", grew >> 20, MAX_RSS_GROWTH >> 20); + } else { + eprintln!("soak seed {seed}: {edits} of {steps} steps edited"); + } } fn steps(default: usize) -> usize { diff --git a/crates/ui-egui/src/ui_soak_tests.rs b/crates/ui-egui/src/ui_soak_tests.rs index edfd169f7..7c5ef3fb2 100644 --- a/crates/ui-egui/src/ui_soak_tests.rs +++ b/crates/ui-egui/src/ui_soak_tests.rs @@ -23,6 +23,17 @@ const MAX_JOURNAL: usize = 10_000; /// Mean wall time per frame, generous for slow CI machines (the test profile is optimized). const MAX_MEAN_FRAME: Duration = Duration::from_millis(250); +/// RSS growth allowed between the warmed-up start and the end of a soak; generous because +/// `cargo test` threads share the process. +const MAX_RSS_GROWTH: u64 = 256 << 20; + +/// Resident set size in bytes, where `/proc` exists; other platforms are not sampled. +/// shortcut: assumes 4 KiB pages, upgrade when a 16 KiB-page target runs the soak. +fn rss_bytes() -> Option { + let statm = std::fs::read_to_string("/proc/self/statm").ok()?; + Some(statm.split_whitespace().nth(1)?.parse::().ok()? * 4096) +} + struct Rng(u64); impl Rng { @@ -166,7 +177,12 @@ fn soak(seed: u64, steps: usize) { let mut log = VecDeque::new(); let t0 = Instant::now(); let mut frames = 0usize; + let mut rss_start = None; for step in 0..steps { + // Sample after a quarter of the run so texture caches and allocator arenas are warm. + if step == steps / 4 { + rss_start = rss_bytes(); + } log.push_back(act(&mut h, &mut r)); if log.len() > 20 { log.pop_front(); @@ -189,6 +205,11 @@ fn soak(seed: u64, steps: usize) { let mean = t0.elapsed() / frames.max(1) as u32; eprintln!("ui soak seed {seed}: {steps} actions, {edits} commands, ~{frames} frames, mean frame {mean:?}"); assert!(mean <= MAX_MEAN_FRAME, "mean frame {mean:?} over {MAX_MEAN_FRAME:?}; seed {seed}"); + if let (Some(start), Some(end)) = (rss_start, rss_bytes()) { + let grew = end.saturating_sub(start); + eprintln!("ui soak seed {seed}: RSS {} -> {} MiB", start >> 20, end >> 20); + assert!(grew <= MAX_RSS_GROWTH, "RSS grew {} MiB over {} MiB; seed {seed}", grew >> 20, MAX_RSS_GROWTH >> 20); + } } fn env(name: &str, default: u64) -> u64 { diff --git a/docs/gaps.md b/docs/gaps.md index 9ec41ee8e..26588b8cf 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -49,7 +49,7 @@ revision history. - **Estimate:** 4–8 h (backend probing outside the process or a safe-mode fallback, a software renderer path). Needs a tester with the hardware. **Beta blocker.** -### Soak testing has no memory or timing budgets +### Soak testing has no memory budget on Windows and macOS - **Evidence:** `crates/engine/src/soak_tests.rs` runs seeded random command sequences over a ~100-slide deck (validity, selection, undo/redo exactness, bounded undo, save/reopen in both formats every 100 steps); `DECKCRAFT_SOAK_STEPS` runs it long. It found a chart `clamp` panic @@ -57,9 +57,10 @@ revision history. seeded random clicks, drags, keys (plain, Ctrl, Shift), typing and scrolling over the sample deck, checking document validity, bounded undo/journal/thumbnail/texture caches, zero caught command and render panics (`Session::panics_caught`, `deckcraft_render::panics_caught`) and a - mean frame under 250 ms; 4 × 3000-action runs are clean. -- **Impact:** long-session crash rate is sampled in CI; RSS is not measured directly. -- **Estimate:** 1–2 h (RSS sampling per platform). + mean frame under 250 ms; 4 × 3000-action runs are clean. Both soaks also sample resident memory + (`/proc/self/statm`) after a quarter of the run and fail if it then grows by more than 256 MiB. +- **Impact:** long-session crash rate is sampled in CI; the RSS budget is checked on Linux only. +- **Estimate:** 1 h (RSS sampling on Windows and macOS). ### A control-server timing test may fail under load - **Evidence:** `silent_refused_peers_do_not_delay_the_next_refusal` in @@ -372,6 +373,7 @@ Detail in [localization-parity.md](localization-parity.md). | Date | Change | Summary | |---|---|---| +| 2026-10-26 | trivial | The engine and UI soaks fail if resident memory grows by more than 256 MiB after warm-up (Linux, from `/proc/self/statm`); Windows and macOS are not sampled yet | | 2026-10-25 | trivial | New entries: copying text and cell ranges (no media, no table), a control-server timing test that may fail under load; Proofing notes that automatic lists follow Replace text as you type and that Backspace puts the typed lead back | | 2026-10-24 | trivial | AutoFormat starts bulleted and numbered lists as you type (`* `, `-- `, `> `, `1. `, `a) ` and the rest), with an AutoCorrect option to turn it off | | 2026-10-22 | minor | Animation Pane ▸ Play From starts the preview at the selected effect; gap 10 keeps the effect gallery (7–13 h) | From dd18f64d3f29639acaa03147cb759b1e3c761bbd Mon Sep 17 00:00:00 2001 From: Harrison Booth <73434116+Harrison-Booth@users.noreply.github.com> Date: Mon, 26 Oct 2026 13:25:47 -0500 Subject: [PATCH 2/7] Soak tests: sample memory through memory-stats on Linux, Windows and macOS --- Cargo.lock | 30 ++++++++++++++++++++--------- crates/engine/Cargo.toml | 1 + crates/engine/src/soak_tests.rs | 6 ++---- crates/ui-egui/Cargo.toml | 1 + crates/ui-egui/src/ui_soak_tests.rs | 6 ++---- 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0986dafc0..3ff5c6bcf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -222,7 +222,7 @@ dependencies = [ "objc2-foundation 0.3.2", "parking_lot", "percent-encoding", - "windows-sys 0.52.0", + "windows-sys 0.61.2", "wl-clipboard-rs", "x11rb", ] @@ -1008,6 +1008,7 @@ dependencies = [ "image", "js-sys", "log", + "memory-stats", "serde", "serde_json", "thiserror 2.0.21", @@ -1218,6 +1219,7 @@ dependencies = [ "egui", "egui_kittest", "log", + "memory-stats", "serde", "serde_json", "skrifa 0.47.0", @@ -1593,7 +1595,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -2700,6 +2702,16 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memory-stats" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c73f5c649995a115e1a0220b35e4df0a1294500477f97a91d0660fb5abeb574a" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "minicov" version = "0.3.8" @@ -2847,7 +2859,7 @@ version = "0.50.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -3320,7 +3332,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -3863,7 +3875,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.12.1", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -3920,7 +3932,7 @@ dependencies = [ "security-framework", "security-framework-sys", "webpki-root-certs", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -4541,10 +4553,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.3.4", + "getrandom 0.4.3", "once_cell", "rustix 1.1.5", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -5461,7 +5473,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] diff --git a/crates/engine/Cargo.toml b/crates/engine/Cargo.toml index cb1f4c29f..062d7ac83 100644 --- a/crates/engine/Cargo.toml +++ b/crates/engine/Cargo.toml @@ -29,6 +29,7 @@ chrono = { workspace = true } [dev-dependencies] deckcraft-anim = { workspace = true } +memory-stats = "1.2.0" zip = { workspace = true } # The browser clock for comment timestamps (wasm has no std::time::SystemTime). diff --git a/crates/engine/src/soak_tests.rs b/crates/engine/src/soak_tests.rs index 25f43f115..da12c74eb 100644 --- a/crates/engine/src/soak_tests.rs +++ b/crates/engine/src/soak_tests.rs @@ -64,11 +64,9 @@ fn params(r: &mut Rng, s: &Session) -> Value { } } -/// Resident set size in bytes, where `/proc` exists; other platforms are not sampled. -/// shortcut: assumes 4 KiB pages, upgrade when a 16 KiB-page target runs the soak. +/// Resident set size in bytes (Linux, Windows and macOS); `None` where the platform can't say. fn rss_bytes() -> Option { - let statm = std::fs::read_to_string("/proc/self/statm").ok()?; - Some(statm.split_whitespace().nth(1)?.parse::().ok()? * 4096) + memory_stats::memory_stats().map(|m| m.physical_mem as u64) } /// RSS growth allowed between the warmed-up start and the end of a soak. Generous: `cargo test` diff --git a/crates/ui-egui/Cargo.toml b/crates/ui-egui/Cargo.toml index 2cf3c2f17..1d20b6388 100644 --- a/crates/ui-egui/Cargo.toml +++ b/crates/ui-egui/Cargo.toml @@ -32,6 +32,7 @@ skrifa = { workspace = true } # kittest's own dev-dependencies do not propagate; tests need both font features explicitly. egui = { workspace = true, features = ["default_fonts", "monochrome_emoji_fonts"] } egui_kittest = { workspace = true, features = ["wgpu", "snapshot"] } +memory-stats = "1.2.0" [build-dependencies] serde_json = { workspace = true } diff --git a/crates/ui-egui/src/ui_soak_tests.rs b/crates/ui-egui/src/ui_soak_tests.rs index 7c5ef3fb2..df836fcad 100644 --- a/crates/ui-egui/src/ui_soak_tests.rs +++ b/crates/ui-egui/src/ui_soak_tests.rs @@ -27,11 +27,9 @@ const MAX_MEAN_FRAME: Duration = Duration::from_millis(250); /// `cargo test` threads share the process. const MAX_RSS_GROWTH: u64 = 256 << 20; -/// Resident set size in bytes, where `/proc` exists; other platforms are not sampled. -/// shortcut: assumes 4 KiB pages, upgrade when a 16 KiB-page target runs the soak. +/// Resident set size in bytes (Linux, Windows and macOS); `None` where the platform can't say. fn rss_bytes() -> Option { - let statm = std::fs::read_to_string("/proc/self/statm").ok()?; - Some(statm.split_whitespace().nth(1)?.parse::().ok()? * 4096) + memory_stats::memory_stats().map(|m| m.physical_mem as u64) } struct Rng(u64); From bb345f28289842b05bcc8ff11bd441751d08a04c Mon Sep 17 00:00:00 2001 From: Harrison Booth <73434116+Harrison-Booth@users.noreply.github.com> Date: Mon, 26 Oct 2026 13:26:10 -0500 Subject: [PATCH 3/7] docs: record which platforms the soak memory budget runs on --- docs/gaps.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/gaps.md b/docs/gaps.md index 26588b8cf..ce08a41b2 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -49,7 +49,7 @@ revision history. - **Estimate:** 4–8 h (backend probing outside the process or a safe-mode fallback, a software renderer path). Needs a tester with the hardware. **Beta blocker.** -### Soak testing has no memory budget on Windows and macOS +### Soak memory budgets run in CI on Linux only - **Evidence:** `crates/engine/src/soak_tests.rs` runs seeded random command sequences over a ~100-slide deck (validity, selection, undo/redo exactness, bounded undo, save/reopen in both formats every 100 steps); `DECKCRAFT_SOAK_STEPS` runs it long. It found a chart `clamp` panic @@ -58,9 +58,12 @@ revision history. deck, checking document validity, bounded undo/journal/thumbnail/texture caches, zero caught command and render panics (`Session::panics_caught`, `deckcraft_render::panics_caught`) and a mean frame under 250 ms; 4 × 3000-action runs are clean. Both soaks also sample resident memory - (`/proc/self/statm`) after a quarter of the run and fail if it then grows by more than 256 MiB. -- **Impact:** long-session crash rate is sampled in CI; the RSS budget is checked on Linux only. -- **Estimate:** 1 h (RSS sampling on Windows and macOS). + (the `memory-stats` dev-dependency: `/proc` on Linux, `GetProcessMemoryInfo` on Windows, Mach + task info on macOS) after a quarter of the run and fail if it then grows by more than 256 MiB. +- **Impact:** long-session crash rate is sampled in CI; the RSS budget is only exercised on Linux + (`ci.yml`), and the Windows and macOS code paths have never run in CI. The engine soak has no + wall-time budget. +- **Estimate:** 1 h (a Windows and macOS test job; a timing budget). ### A control-server timing test may fail under load - **Evidence:** `silent_refused_peers_do_not_delay_the_next_refusal` in @@ -373,7 +376,7 @@ Detail in [localization-parity.md](localization-parity.md). | Date | Change | Summary | |---|---|---| -| 2026-10-26 | trivial | The engine and UI soaks fail if resident memory grows by more than 256 MiB after warm-up (Linux, from `/proc/self/statm`); Windows and macOS are not sampled yet | +| 2026-10-26 | trivial | The engine and UI soaks fail if resident memory grows by more than 256 MiB after warm-up (through `memory-stats`: Linux, Windows and macOS; only Linux runs in CI) | | 2026-10-25 | trivial | New entries: copying text and cell ranges (no media, no table), a control-server timing test that may fail under load; Proofing notes that automatic lists follow Replace text as you type and that Backspace puts the typed lead back | | 2026-10-24 | trivial | AutoFormat starts bulleted and numbered lists as you type (`* `, `-- `, `> `, `1. `, `a) ` and the rest), with an AutoCorrect option to turn it off | | 2026-10-22 | minor | Animation Pane ▸ Play From starts the preview at the selected effect; gap 10 keeps the effect gallery (7–13 h) | From 23f0cd1c9f3123b9983c42ef9139144e0a4f3b2a Mon Sep 17 00:00:00 2001 From: Harrison Booth <73434116+Harrison-Booth@users.noreply.github.com> Date: Mon, 26 Oct 2026 13:44:25 -0500 Subject: [PATCH 4/7] Soak tests: say the Windows value is the working set --- crates/engine/src/soak_tests.rs | 7 ++++--- crates/ui-egui/src/ui_soak_tests.rs | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/soak_tests.rs b/crates/engine/src/soak_tests.rs index da12c74eb..f1f5f970e 100644 --- a/crates/engine/src/soak_tests.rs +++ b/crates/engine/src/soak_tests.rs @@ -64,7 +64,8 @@ fn params(r: &mut Rng, s: &Session) -> Value { } } -/// Resident set size in bytes (Linux, Windows and macOS); `None` where the platform can't say. +/// Physical memory in use, in bytes: the resident set size on Linux and macOS, the working set on +/// Windows. `None` where the platform cannot say. fn rss_bytes() -> Option { memory_stats::memory_stats().map(|m| m.physical_mem as u64) } @@ -156,8 +157,8 @@ fn soak(seed: u64, steps: usize) { assert!(edits * 10 >= steps, "only {edits} of {steps} steps changed the document; seed {seed}"); if let (Some(start), Some(end)) = (rss_start, rss_bytes()) { let grew = end.saturating_sub(start); - eprintln!("soak seed {seed}: {edits} of {steps} steps edited, RSS {} -> {} MiB", start >> 20, end >> 20); - assert!(grew <= MAX_RSS_GROWTH, "RSS grew {} MiB over {} MiB; seed {seed}", grew >> 20, MAX_RSS_GROWTH >> 20); + eprintln!("soak seed {seed}: {edits} of {steps} steps edited, memory {} -> {} MiB", start >> 20, end >> 20); + assert!(grew <= MAX_RSS_GROWTH, "memory grew {} MiB over {} MiB; seed {seed}", grew >> 20, MAX_RSS_GROWTH >> 20); } else { eprintln!("soak seed {seed}: {edits} of {steps} steps edited"); } diff --git a/crates/ui-egui/src/ui_soak_tests.rs b/crates/ui-egui/src/ui_soak_tests.rs index df836fcad..71e848a37 100644 --- a/crates/ui-egui/src/ui_soak_tests.rs +++ b/crates/ui-egui/src/ui_soak_tests.rs @@ -27,7 +27,8 @@ const MAX_MEAN_FRAME: Duration = Duration::from_millis(250); /// `cargo test` threads share the process. const MAX_RSS_GROWTH: u64 = 256 << 20; -/// Resident set size in bytes (Linux, Windows and macOS); `None` where the platform can't say. +/// Physical memory in use, in bytes: the resident set size on Linux and macOS, the working set on +/// Windows. `None` where the platform cannot say. fn rss_bytes() -> Option { memory_stats::memory_stats().map(|m| m.physical_mem as u64) } @@ -205,8 +206,8 @@ fn soak(seed: u64, steps: usize) { assert!(mean <= MAX_MEAN_FRAME, "mean frame {mean:?} over {MAX_MEAN_FRAME:?}; seed {seed}"); if let (Some(start), Some(end)) = (rss_start, rss_bytes()) { let grew = end.saturating_sub(start); - eprintln!("ui soak seed {seed}: RSS {} -> {} MiB", start >> 20, end >> 20); - assert!(grew <= MAX_RSS_GROWTH, "RSS grew {} MiB over {} MiB; seed {seed}", grew >> 20, MAX_RSS_GROWTH >> 20); + eprintln!("ui soak seed {seed}: memory {} -> {} MiB", start >> 20, end >> 20); + assert!(grew <= MAX_RSS_GROWTH, "memory grew {} MiB over {} MiB; seed {seed}", grew >> 20, MAX_RSS_GROWTH >> 20); } } From 9e00c7ae9b7994d3154af5f8272ee2dfaa280ad6 Mon Sep 17 00:00:00 2001 From: Harrison Booth <73434116+Harrison-Booth@users.noreply.github.com> Date: Tue, 27 Oct 2026 21:06:00 -0500 Subject: [PATCH 5/7] Soak tests: take the memory baseline after at least one completed action --- crates/ui-egui/src/ui_soak_tests.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/ui_soak_tests.rs b/crates/ui-egui/src/ui_soak_tests.rs index 71e848a37..db6761e38 100644 --- a/crates/ui-egui/src/ui_soak_tests.rs +++ b/crates/ui-egui/src/ui_soak_tests.rs @@ -178,11 +178,12 @@ fn soak(seed: u64, steps: usize) { let mut frames = 0usize; let mut rss_start = None; for step in 0..steps { - // Sample after a quarter of the run so texture caches and allocator arenas are warm. - if step == steps / 4 { + log.push_back(act(&mut h, &mut r)); + // Sample after a quarter of the run, and after at least one action, so texture caches and + // allocator arenas are warm. + if step + 1 == (steps / 4).max(1) { rss_start = rss_bytes(); } - log.push_back(act(&mut h, &mut r)); if log.len() > 20 { log.pop_front(); } From 4885a1724dcf4826ba1ca23ca2c1c61f17e66924 Mon Sep 17 00:00:00 2001 From: Harrison Booth <73434116+Harrison-Booth@users.noreply.github.com> Date: Thu, 5 Nov 2026 08:14:12 -0600 Subject: [PATCH 6/7] Sample UI soak memory after action frames --- crates/ui-egui/src/ui_soak_tests.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/ui_soak_tests.rs b/crates/ui-egui/src/ui_soak_tests.rs index db6761e38..5e3fa4eae 100644 --- a/crates/ui-egui/src/ui_soak_tests.rs +++ b/crates/ui-egui/src/ui_soak_tests.rs @@ -179,16 +179,16 @@ fn soak(seed: u64, steps: usize) { let mut rss_start = None; for step in 0..steps { log.push_back(act(&mut h, &mut r)); - // Sample after a quarter of the run, and after at least one action, so texture caches and - // allocator arenas are warm. - if step + 1 == (steps / 4).max(1) { - rss_start = rss_bytes(); - } if log.len() > 20 { log.pop_front(); } h.run_steps(2); frames += 8; + // Sample after a quarter of the run and its frames, so texture caches and allocator arenas + // are warm. Short runs sample only after their first completed action. + if step + 1 == (steps / 4).max(1) { + rss_start = rss_bytes(); + } if step % 10 == 9 { check(&h, seed, step, &log); } From 9e73fef15877f6ea37a33ae81f158629a2637f02 Mon Sep 17 00:00:00 2001 From: "autocraft-bot[bot]" <354215646+autocraft-bot[bot]@users.noreply.github.com> Date: Wed, 2 Dec 2026 21:22:56 +0000 Subject: [PATCH 7/7] I removed the `NEXTEST` gate, so `rss_bytes()` reads memory on every run I removed the `NEXTEST` gate, so `rss_bytes()` reads memory on every run again and the 256 MiB growth check applies under plain `cargo test`. To stop other tests' allocations from tripping it, the engine soak tests (`soak_random_edits_keep_the_document_valid` and the ignored `soak_long`) now call a new `alone()` helper in `soak_tests.rs`. Under nextest, which already gives each test its own process, or inside a child process, `alone()` returns true and the soak runs. Under plain `cargo test` it re-runs the test binary on that single test (`--exact --test-threads=1`) in a child process. It sets `DECKCRAFT_SOAK_ALONE` so the child runs the soak, and it fails the parent test if the child fails. `cargo fmt --check` is clean. `cargo clippy` on the engine tests shows no warnings in the engine crate; its only warning is one `needless_bool` in `deckcraft-pptx`. `cargo test -p deckcraft-engine --lib soak` passes and takes 36 s. I did not repeat the run to see whether the intermittent failure stays gone. I made no changes to the UI soak. --- crates/engine/src/soak_tests.rs | 36 +++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/soak_tests.rs b/crates/engine/src/soak_tests.rs index f1f5f970e..d1777ff35 100644 --- a/crates/engine/src/soak_tests.rs +++ b/crates/engine/src/soak_tests.rs @@ -70,8 +70,34 @@ fn rss_bytes() -> Option { memory_stats::memory_stats().map(|m| m.physical_mem as u64) } -/// RSS growth allowed between the warmed-up start and the end of a soak. Generous: `cargo test` -/// threads share the process, so other tests' allocations count too. +/// Whether this process may run the named soak itself, so its memory reading is its own. +/// +/// The reading is for the whole process, and plain `cargo test` runs every test of the crate on +/// threads of one process, so other tests' allocations would count against the budget. nextest +/// runs each test in its own process (and sets `NEXTEST`). Anywhere else the test runs itself again +/// in a child process of its own, which takes this branch, and fails if the child does. +fn alone(test: &str) -> bool { + const MARK: &str = "DECKCRAFT_SOAK_ALONE"; + if std::env::var_os("NEXTEST").is_some() || std::env::var_os(MARK).is_some() { + return true; + } + let path = module_path!().split_once("::").map_or(module_path!(), |(_, rest)| rest); + let out = std::process::Command::new(std::env::current_exe().expect("test binary path")) + .args(["--exact", &format!("{path}::{test}"), "--include-ignored", "--test-threads=1", "--nocapture"]) + .env(MARK, "1") + .output() + .expect("run the soak in its own process"); + assert!( + out.status.success(), + "soak {test} failed in its own process:\n{}\n{}", + String::from_utf8_lossy(&out.stdout), + String::from_utf8_lossy(&out.stderr) + ); + false +} + +/// RSS growth allowed between the warmed-up start and the end of a soak, with the test alone in +/// its process (see `alone`). const MAX_RSS_GROWTH: u64 = 256 << 20; fn doc(s: &Session) -> Option { @@ -170,6 +196,9 @@ fn steps(default: usize) -> usize { #[test] fn soak_random_edits_keep_the_document_valid() { + if !alone("soak_random_edits_keep_the_document_valid") { + return; + } for seed in [1, 0xDEC0_C2AF, 42, 7_777_777] { soak(seed, steps(400)); } @@ -178,6 +207,9 @@ fn soak_random_edits_keep_the_document_valid() { #[test] #[ignore = "long soak; set DECKCRAFT_SOAK_STEPS"] fn soak_long() { + if !alone("soak_long") { + return; + } let seed = std::env::var("DECKCRAFT_SOAK_SEED").ok().and_then(|v| v.parse().ok()).unwrap_or(0x5EED); soak(seed, steps(20_000)); }