Compare commits

...
Author SHA1 Message Date
autocraft-bot[bot] 6957219245 Merge main (577ada30) into the pull request
Resolved conflicts in Cargo.lock and crates/ui-egui/Cargo.toml by keepin

Resolved conflicts in Cargo.lock and crates/ui-egui/Cargo.toml by keeping both sides: egui_kittest gets main's `eframe` feature, the PR's memory-stats dev-dependency stays, and the lock holds both memory-stats and mime. cargo check --offline --locked --tests passes for deckcraft-ui-egui and deckcraft-engine; I did not run the tests.
2026-12-03 04:45:56 +00:00
autocraft-bot[bot] 9e73fef158 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.
2026-12-02 21:22:56 +00:00
Harrison Booth 4885a1724d Sample UI soak memory after action frames 2026-11-05 08:14:12 -06:00
Harrison Booth 72e3055b3b Merge remote-tracking branch 'origin/main' into dc-soak-rss 2026-11-05 08:11:42 -06:00
Harrison Booth c462f658ab Merge current main into soak RSS branch 2026-11-03 09:48:15 -06:00
Harrison Booth 9e00c7ae9b Soak tests: take the memory baseline after at least one completed action 2026-10-27 21:06:00 -05:00
Harrison Booth 23f0cd1c9f Soak tests: say the Windows value is the working set 2026-10-26 13:44:25 -05:00
Harrison Booth bb345f2828 docs: record which platforms the soak memory budget runs on 2026-10-26 13:26:10 -05:00
Harrison Booth dd18f64d3f Soak tests: sample memory through memory-stats on Linux, Windows and macOS 2026-10-26 13:25:47 -05:00
Harrison Booth 8519680df0 Soak tests: fail on resident memory growth after warm-up 2026-10-26 13:08:52 -05:00
6 changed files with 98 additions and 5 deletions
Generated
+12
View File
@@ -2486,6 +2486,7 @@ dependencies = [
"image",
"js-sys",
"log",
"memory-stats",
"serde",
"serde_json",
"thiserror 2.0.21",
@@ -2670,6 +2671,7 @@ dependencies = [
"egui",
"egui_kittest",
"log",
"memory-stats",
"serde",
"serde_json",
"skrifa 0.47.0",
@@ -4948,6 +4950,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 = "mime"
version = "0.3.18"
+1
View File
@@ -31,6 +31,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).
+54 -1
View File
@@ -64,6 +64,42 @@ fn params(r: &mut Rng, s: &Session) -> Value {
}
}
/// 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<u64> {
memory_stats::memory_stats().map(|m| m.physical_mem as u64)
}
/// 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<deckcraft_model::Presentation> {
s.active().map(|d| (*d.doc).clone())
}
@@ -91,7 +127,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 +181,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, 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");
}
}
fn steps(default: usize) -> usize {
@@ -149,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));
}
@@ -157,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));
}
+1
View File
@@ -38,6 +38,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", "eframe"] }
memory-stats = "1.2.0"
[build-dependencies]
serde_json = { workspace = true }
+21
View File
@@ -23,6 +23,16 @@ 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;
/// 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<u64> {
memory_stats::memory_stats().map(|m| m.physical_mem as u64)
}
struct Rng(u64);
impl Rng {
@@ -161,6 +171,7 @@ 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 {
log.push_back(act(&mut h, &mut r));
if log.len() > 20 {
@@ -168,6 +179,11 @@ fn soak(seed: u64, steps: usize) {
}
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);
}
@@ -184,6 +200,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}: memory {} -> {} MiB", start >> 20, end >> 20);
assert!(grew <= MAX_RSS_GROWTH, "memory grew {} MiB over {} MiB; seed {seed}", grew >> 20, MAX_RSS_GROWTH >> 20);
}
}
fn env(name: &str, default: u64) -> u64 {
+9 -4
View File
@@ -48,7 +48,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 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
@@ -56,9 +56,13 @@ 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
(`memory-stats`: `/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).
## File formats
@@ -367,6 +371,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 (through `memory-stats`: Linux, Windows and macOS; only Linux runs in CI) |
| 2026-11-02 | trivial | Run alternate-language metadata now survives native and PPTX saves; UI and proofing gaps remain; scores unchanged |
| 2026-11-02 | trivial | PPTX reflection geometry is retained through native and PPTX resaves; no rendering parity claim |
| 2026-11-02 | trivial | Reused slide geometry and content scale to the destination; picker thumbnails remain the reuse gap |