Skip to content

bench(render): N-session baseline harness for the daemon epic (#14) - #26

Merged
axisrow merged 2 commits into
mainfrom
feat/benchmark-baseline
Sep 27, 2026
Merged

axisrow merged 2 commits into
mainfrom
feat/benchmark-baseline

Conversation

@axisrow

@axisrow axisrow commented Sep 27, 2026

Copy link
Copy Markdown
Owner

What

Extends scripts/benchmark-render.py (the sirmalloc#397 render benchmark) into an N-session baseline harness for the daemon epic #14 — and commits the measured one-shot baseline. No daemon code, no src/ changes; only scripts/ and docs/.

Closes nothing; provides the red-line reference for #14: the daemon's aggregate CPU and RSS must not exceed these numbers.

Harness (scripts/benchmark-render.py, stdlib only)

  • Modes: legacy single-run (benchmark-render.py <runtime> <entry> <label>, unchanged), plus baseline / run-one / _sampler, plus --self-test.
  • Scenarios: {1, 10, 36} concurrent sessions × {cold, warm} × {small 0.62 MB, large 11.5 MB} transcripts = 12 timing scenarios + 12 instrumented count passes + 2 extra repeats of s36-warm-small (run-to-run variance). Each scenario runs in a dedicated child interpreter so getrusage(RUSAGE_CHILDREN) starts at zero — CPU user+sys covers the runtime and all reaped descendants (git, sh).
  • Metrics per scenario: aggregate CPU-s per render and per wall-minute (incl. children), peak RSS (ru_maxrss), aggregate RSS (ps-sampled live process tree, mean→max), wall latency p50/p95/p99, git/security spawn counts, output hashes, machine context and per-scenario loadavg stamps.
  • Spawn counts come from separate instrumented passes (PATH shims that log and exec the real binary); their CPU/latency never enters baseline tables.
  • Built-in loadavg gate: a scenario is measured only below the gate (this run: 10 on 10 cores); runs are stamped with loadavg at measured-phase start/end.

Reproduce:

bun install && bun run build
python3 scripts/benchmark-render.py baseline --runtime node --entry dist/ccstatusline.js --out /tmp/ccsl-baseline-14 --max-load 10

Baseline (Apple M5, 10 cores, node dist/ccstatusline.js, CCSL_FORK=1, 26/26 runs OK)

Cold = fresh HOME, first render per session; warm = 2 warmups then 6 measured renders/session (persistent git cache populated, steady state). All sessions share one HOME per run (same-OS-user realism, the daemon's target) and one dirty git repo as cwd; each session has its own transcript.

scenario CPU s/render CPU s/wall-min peak RSS MB agg RSS MB mean→max p50 / p95 / p99 ms git spawns/render
s1-cold-small 328.2 42.8 76.1 64.1→75.8 447 / 447 / 447 4.0
s1-warm-small 239.4 59.9 76.5 49.8→75.3 233 / 280 / 280 0.0
s1-cold-large 325.9 60.1 95.8 71.3→95.1 321 / 321 / 321 4.0
s1-warm-large 323.6 47.7 99.4 54.1→89.7 315 / 627 / 627 0.0
s10-cold-small 290.2 219.9 73.9 567.4→721.2 748 / 758 / 758 3.6
s10-warm-small 303.6 69.3 76.9 474.0→666.8 2664 / 3501 / 4070 0.0
s10-cold-large 359.9 178.4 94.0 603.1→889.8 1169 / 1198 / 1198 2.4
s10-warm-large 239.1 247.6 102.4 624.7→786.0 573 / 705 / 744 0.0
s36-cold-small 199.5 248.2 75.0 1465.1→2078.6 1383 / 1557 / 1568 1.5
s36-warm-small 198.7 206.6 77.4 1792.0→2364.4 1991 / 2605 / 2773 0.0
s36-cold-large 218.5 272.5 98.5 1799.9→2654.2 1463 / 1624 / 1657 1.7
s36-warm-large 248.1 190.6 107.9 1823.8→2554.1 2675 / 3925 / 4178 0.0

security spawns: 0.0 everywhere. Full 26-run machine-readable data (per-render latency arrays, loadavg stamps, hashes): docs/baseline-14-results.json; methodology and noise notes: docs/baseline-14-verification.md.

Run-to-run variance (s36-warm-small ×3)

run CPU s/render agg RSS MB max p95 ms
r1 198.7 2364.4 2605
r2 185.0 2511.0 2135
r3 191.4 2466.0 2826

CPU/render spread ~7%, aggregate RSS ~6%; latency is noisier under ambient load, as expected.

How the daemon red line uses this

Warm, 36 sessions anchors: ~207 CPU-seconds per wall-minute at ~1040 renders/wall-min, ~1.8–2.4 GB aggregate RSS across ~36 concurrent process trees (75–108 MB peak each), 0 git spawns/render warm vs 4.0 cold. A daemon prototype at N sessions must match renders at aggregate CPU and RSS not above the matching baseline row; the cold table bounds the all-sessions-repaint burst after a daemon restart.

Honesty notes

  • Measured numbers only, no extrapolation; every scenario stamped with its own loadavg.
  • The machine was not idle (ambient loadavg ~8–40 from sibling agent sessions); the gate kept measurements out of the worst spikes, two rows that landed on spikes were re-measured and replaced (documented in the JSON notes). CPU/RSS are empirically load-stable (variance table spans loadavg 10–29); latency percentiles are upper bounds for an idle machine.
  • Cold spawn counts decrease with session count (4.0 → 1.5) because 36 concurrent first renders share one HOME's persistent git cache — same-user realism, not an artifact.
  • Spawns via absolute paths (e.g. runtime self-spawn for git-review refresh) are not shim-visible; the synthetic repo has no origin, so review-cache refresh does not trigger.
  • bun run lint: tsc --noEmit clean; ESLint reports 21 pre-existing errors on origin/main files, none from this branch (which touches only scripts/ and docs/).

Risks / follow-ups

  • Ambient-load environment means latency rows are conservative; re-run on a quiet machine for tighter latency before any latency-focused daemon claims.
  • --self-test covers percentile/fixture/shim logic; full-matrix runtime is bounded (~10–15 min of measuring plus gate waits).

🤖 Generated with Claude Code

axisrow added a commit that referenced this pull request Sep 27, 2026
The fork's main branch is already red: 21 eslint errors across
PowerlineThemeSelector.tsx (+test), renderer-regular-theme.test.ts,
separator-font-fallback.test.ts, cli.ts, powerline.ts and renderer.ts
from earlier theme/CLI merges. Every PR fails "Lint & Type Check" on
them, including #26, whose own files are clean.

Mechanical, behavior-preserving fixes:
- 17 auto-fixed via `bun run lint:fix` (arrow-parens, indent,
  import order/newlines)
- powerline.ts: `if (x === null) x = f()` -> `x ??= f()` (type is
  `PowerlineFontStatus | null`, so ??= is exactly equivalent)
- renderer-regular-theme.test.ts: replace `first!`/`second!` (banned by
  no-non-null-assertion; demanded by non-nullable-type-assertion-style)
  with an explicit narrowing throw - a stronger check than the previous
  toBeDefined() pair
- PowerlineThemeSelector.test.ts: `.filter(...)[0]` -> `.find(...)`

bun run lint: clean. bun test: 2494 pass, 0 fail.

Co-Authored-By: Claude Code <noreply@anthropic.com>
axisrow and others added 2 commits September 27, 2026 10:51
Extend scripts/benchmark-render.py with a baseline mode: 1/10/36
concurrent sessions, cold/warm, small/large transcripts. Per-scenario
child interpreters give clean getrusage(RUSAGE_CHILDREN) CPU accounting
including all descendants; RSS via ru_maxrss peak plus ps-sampled
aggregate; wall latency p50/p95/p99; PATH-shim instrumented passes count
git/security spawns. Built-in loadavg gate and per-scenario load stamps.

Results (26/26 runs, Apple M5, node dist): docs/baseline-14-results.json,
methodology and tables: docs/baseline-14-verification.md. Legacy sirmalloc#397
single-run mode unchanged. No daemon code, no src/ changes.

Red line for #14 (warm, 36 sessions): ~207 CPU-s/wall-min, agg RSS
1.8-2.4 GB, 0 git spawns/render warm, 4.0 cold.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
@axisrow
axisrow force-pushed the feat/benchmark-baseline branch from 2e3aa4c to e263db9 Compare September 27, 2026 02:57
@axisrow
axisrow merged commit a04916c into main Sep 27, 2026
6 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.

1 participant