Skip to content

Add daemon memory soak benchmark - #54

Merged
hongnoul merged 1 commit into
mainfrom
perf/issue-48-soak
Aug 3, 2026
Merged

Add daemon memory soak benchmark#54
hongnoul merged 1 commit into
mainfrom
perf/issue-48-soak

Conversation

@hongnoul

@hongnoul hongnoul commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Closes #48

Summary

  • add scripts/soak-daemon-rss.sh, a configurable deterministic local daemon memory soak
  • exercise repeated goto + shot + snapshot rounds against an isolated fixture by default
  • record per-round process-tree memory CSV plus machine-readable summary.json
  • make growth failure opt-in via --fail-on-growth / HWATU_SOAK_FAIL_ON_GROWTH=1
  • document usage, measurement method, cleanup/isolation, and the host run in docs/benchmarks.md

Measurement

Final practical short run on this host:

scripts/soak-daemon-rss.sh --rounds 30 --warmup 5 --no-build --out .jcode-soak-results --keep

Result: process-tree PSS from proc smaps_rollup stayed bounded:

  • baseline: 237,070 kB
  • final: 228,854 kB
  • peak: 239,450 kB
  • growth: -3.47%
  • threshold exceeded: false

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 --release
  • bash -n scripts/soak-daemon-rss.sh scripts/soak-watch.sh scripts/bench-spawn.sh
  • scripts/soak-daemon-rss.sh --self-test
  • scripts/soak-daemon-rss.sh --rounds 3 --warmup 1 --no-build --out .jcode-soak-smoke --keep
  • scripts/soak-daemon-rss.sh --rounds 30 --warmup 5 --no-build --out .jcode-soak-results --keep
  • cargo fmt --check
  • cargo test -p hwatu
  • cargo test -p hwatud

Note: shellcheck was not installed on this host, so shell validation used bash -n plus the benchmark self-test and smoke runs.

@hongnoul hongnoul left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 hongnoul left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@hongnoul
hongnoul merged commit 02c4a02 into main Aug 3, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

signal: long-lived browser-daemon RSS growth is a repeat-use killer for competitors; prove hwatud stays flat with a soak benchmark

1 participant