Skip to content

feat(snmalloc-tools): rate-report subcommand + snapshot-vs-streaming docs - #73

Merged
jayakasadev merged 1 commit into
mainfrom
feat/snmalloc-tools-rate-report
Jun 16, 2026
Merged

jayakasadev merged 1 commit into
mainfrom
feat/snmalloc-tools-rate-report

Conversation

@jayakasadev

Copy link
Copy Markdown
Owner

What: new snmalloc-tools rate-report subcommand — stream-parses a JSON-Lines streaming event log and emits per-site rows (site, alloc_count, dealloc_count, peak_live_bytes, alloc_rate_per_sec) as CSV (default) or a fixed-width table (--pretty). Also adds a "When to use snapshot vs streaming" section to snmalloc-rs/README.md and documents the streaming-log on-disk schema in snmalloc-tools/README.md.

Why: snapshot() is biased toward long-lived state and misses transient churn — a hot allocate-and-free site disappears before the snapshot is taken. Operators optimising a hot path need per-site allocation rate, which only the streaming-log path can answer. This adds the offline analysis half (the producer half is the existing ProfilingSession::start callback).

Cost: ~390 LOC in snmalloc-tools/src/rate_report.rs + ~30 LOC main.rs wiring + ~150 LOC tests + ~80 LOC README. No new crate deps (reuses serde/serde_json/anyhow/clap already in the manifest). Strictly streaming reader: 6M-event logs use O(distinct sites) memory, not O(events).

Evidence: cargo test -p snmalloc-tools — 26 unit tests + 6 existing integration tests + 8 new rate_report.rs integration tests all pass. cargo run -p snmalloc-tools -- rate-report --help shows the subcommand with --input, --top, --pretty. cargo build -p snmalloc-tools clean. Local verification only (CI on fork is workflow_dispatch).

…docs

Adds a `rate-report` subcommand to snmalloc-tools that stream-parses a
JSON-Lines streaming event log and emits per-site (alloc_count,
dealloc_count, peak_live_bytes, alloc_rate_per_sec) rows as CSV or a
fixed-width table.  Reader is strictly streaming — 6M-event logs use
O(distinct sites) memory.  Defines the JSONL on-disk schema for
snmalloc streaming sessions (kind / site / size / ts_ns).

Adds a "When to use snapshot vs streaming" section to snmalloc-rs
README documenting the tradeoff: snapshot biased toward long-lived
state, streaming captures transient churn — use streaming +
rate-report for hot-path alloc-rate optimisation.

New integration tests cover library round-trip and CLI surface
(--help, default CSV, --pretty, --top truncation) against a worked
8-event fixture.
@jayakasadev
jayakasadev merged commit 54cf4c4 into main Jun 16, 2026
@jayakasadev
jayakasadev deleted the feat/snmalloc-tools-rate-report branch June 16, 2026 15:51
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