Soak tests: fail on resident memory growth after warm-up

This commit is contained in:
Harrison Booth
2026-10-26 13:08:52 -05:00
parent aaf6c1c38a
commit 8519680df0
3 changed files with 50 additions and 5 deletions
+23 -1
View File
@@ -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<u64> {
let statm = std::fs::read_to_string("/proc/self/statm").ok()?;
Some(statm.split_whitespace().nth(1)?.parse::<u64>().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<deckcraft_model::Presentation> {
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<String> = 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 {
+21
View File
@@ -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<u64> {
let statm = std::fs::read_to_string("/proc/self/statm").ok()?;
Some(statm.split_whitespace().nth(1)?.parse::<u64>().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 {
+6 -4
View File
@@ -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) |