Skip to content

feat(snmalloc-rs): linux-pinned bench harness for ticket 86aj0jg36#77

Open
jayakasadev wants to merge 1 commit into
mainfrom
feature/linux-pinned-bench-script
Open

feat(snmalloc-rs): linux-pinned bench harness for ticket 86aj0jg36#77
jayakasadev wants to merge 1 commit into
mainfrom
feature/linux-pinned-bench-script

Conversation

@jayakasadev

Copy link
Copy Markdown
Owner

What

snmalloc-rs/scripts/run-linux-pinned-bench.sh — one-shot Linux desktop bench runner that does setup, run, extract, cleanup for the heap-profiling perf ticket 86aj0jg36.

Also bumps medium_allocs + mixed groups in profile_bench.rs from sample_size=50 / measurement_time=5s to 200 / 20s per ticket spec. small_allocs left alone (already noise-dominated).

Why

macOS M4 Pro variance (~4-7% σ) > residual perf gap (<1% target). Confirmed today: with the new sample bump on macOS, mixed/profile-on-inactive hit a 113% CoV cell — thermally throttled / scheduler-migrated during a 20s sustained run. Not decisive.

Ticket calls for: bare-metal Linux desktop, taskset -c 0, cpufreq -g performance, no turbo, no SMT sibling. Script automates the full recipe so the result is reproducible.

Script extracts the criterion JSON into a paste-ready markdown table + JSON archive + host fingerprint sidecar — drop the four output files in a follow-up commit on this branch and the ticket closes.

Cost

  • Script: 0 runtime cost (manual workflow_dispatch-style — user invokes on their own Linux box).
  • Bench wall-clock per run: ~10min (small ~30s + medium ~4min + mixed ~4min + extract <1s).
  • Disk: ~5KB output files + criterion HTML reports under target/criterion/.
  • Repo footprint: 1 script (~330 lines including comments), 4 added lines in profile_bench.rs.

Evidence

  • bash -n clean.
  • shellcheck clean modulo two false-positive disables (SC2294 eval-with-redirect is intentional for --dry-run; SC2054 misreads --preserve-env=HOME,PATH,... commas as array separators).
  • cargo check --bench profile_bench --features profiling clean after the profile_bench.rs bump.
  • Trap-based cleanup verified by code inspection: governor + boost + SMT state captured before apply_setup, restored via bash $STATE_FILE in EXIT trap regardless of success/fail/Ctrl-C.

Follow-up

  1. User runs sudo ./snmalloc-rs/scripts/run-linux-pinned-bench.sh on Linux desktop.
  2. Commits snmalloc-rs/bench-results/linux-pinned-bench.{log,json,md} + linux-pinned-bench-host.txt to this branch.
  3. I update docs/heap-profiling-benchmarks.md with the Linux column.
  4. If every ratio < 1.01 → close ticket 86aj0jg36 + perf ticket 86aj0hfmc.

…t 86aj0jg36

Adds snmalloc-rs/scripts/run-linux-pinned-bench.sh which executes the
recipe described in ticket 86aj0jg36 on a bare-metal Linux desktop so
the residual idle/active overhead numbers can be measured below the
macOS bench harness's ~4-7% sigma. The script:

  * saves cpufreq governor, boost flag, and SMT-sibling online state;
  * locks all cpus to "performance", disables turbo/boost, and offlines
    the SMT sibling of the bench cpu so the bench thread owns its
    physical core's L1/L2 alone;
  * best-effort stops snapd / packagekit / unattended-upgrades / cron;
  * runs `cargo bench --features profiling --bench profile_bench` with
    `taskset -c <cpu>` (default cpu0);
  * extracts target/criterion/*/new/estimates.json into a paste-ready
    markdown summary + JSON archive + host-fingerprint sidecar;
  * always restores host state on exit via an EXIT trap.

Also bumps `medium_allocs` and `mixed` groups in profile_bench.rs from
sample_size=50/measurement_time=5s to 200/20s per the ticket spec. The
`small_allocs` group is already noise-dominated at the old settings and
is left alone. The new settings cost ~10 minutes per run instead of ~4.

Outputs land under snmalloc-rs/bench-results/ by default (configurable
via --output-dir). Push the generated linux-pinned-bench.{log,json,md}
plus linux-pinned-bench-host.txt back here in a follow-up commit to
close ticket 86aj0jg36.

Usage:
  sudo ./snmalloc-rs/scripts/run-linux-pinned-bench.sh                  # defaults
  sudo ./snmalloc-rs/scripts/run-linux-pinned-bench.sh --cpu 2 --out /tmp/bench
  sudo ./snmalloc-rs/scripts/run-linux-pinned-bench.sh --no-offline-smt
  sudo ./snmalloc-rs/scripts/run-linux-pinned-bench.sh --dry-run
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