Add daemon memory soak benchmark - #54
Conversation
hongnoul
left a comment
There was a problem hiding this comment.
Review verdict: changes requested (comment-only self-review).
P1 – the default path can benchmark stale binaries. In scripts/soak-daemon-rss.sh, build=1 runs cargo build --release only when target/release/hwatu or hwatud is missing. If binaries already exist after source changes, the benchmark silently exercises old code. That makes the published curve and future regression checks untrustworthy, and makes --no-build effectively indistinguishable from the default in the common case. Run the release build unconditionally unless --no-build is supplied, or verify a source/commit stamp before reusing binaries. Add a self-test for this distinction.
Validation: CI is green; bash -n scripts/soak-daemon-rss.sh and scripts/soak-daemon-rss.sh --self-test both passed independently.
hongnoul
left a comment
There was a problem hiding this comment.
Follow-up finding from an independent pass:
P1 – a slow daemon startup can spawn an untracked second daemon. After the 5-second socket loop, the script falls through without checking that the socket exists or that $daemon_pid is alive, then runs hwatu ping. The client auto-spawns hwatud when it cannot connect, so a slow/compositor-less startup can create a second daemon that cleanup does not own. Hard-fail after the wait if the socket is absent or the tracked daemon exited. Also force LC_ALL=C around the awk-generated JSON number so locales using decimal commas cannot produce invalid summary.json, and keep the metric method fixed across baseline/final samples.
These are in addition to the stale-binary default noted in the first review.
Closes #48
Summary
scripts/soak-daemon-rss.sh, a configurable deterministic local daemon memory soakgoto+shot+snapshotrounds against an isolated fixture by defaultsummary.json--fail-on-growth/HWATU_SOAK_FAIL_ON_GROWTH=1docs/benchmarks.mdMeasurement
Final practical short run on this host:
Result: process-tree PSS from proc smaps_rollup stayed bounded:
No unbounded ratchet observed. A strict post-cleanup scan for the isolated temp path also found 0 retained isolated soak processes; broad WebKit children on the host belonged to the primary user daemon or other worktrees, not this benchmark run.
Validation
cargo build --releasebash -n scripts/soak-daemon-rss.sh scripts/soak-watch.sh scripts/bench-spawn.shscripts/soak-daemon-rss.sh --self-testscripts/soak-daemon-rss.sh --rounds 3 --warmup 1 --no-build --out .jcode-soak-smoke --keepscripts/soak-daemon-rss.sh --rounds 30 --warmup 5 --no-build --out .jcode-soak-results --keepcargo fmt --checkcargo test -p hwatucargo test -p hwatudNote:
shellcheckwas not installed on this host, so shell validation usedbash -nplus the benchmark self-test and smoke runs.