Skip to content

feat(benchmarks): add oven-sh/mimalloc (Bun) as a fifth allocator row (#325) - #330

Merged
zackees merged 11 commits into
mainfrom
feat/325-bun-benchmark-row
Sep 3, 2026
Merged

zackees merged 11 commits into
mainfrom
feat/325-bun-benchmark-row

Conversation

@zackees

@zackees zackees commented Sep 3, 2026 •

Copy link
Copy Markdown
Owner

Adds oven-sh/mimalloc (Bun's fork) as a fifth allocator row in the benchmark
suite, the dashboard, the workflows and the docs. Closes the "we're a superset
and no slower than Bun" claim being an assumption from shared code rather than
a measurement.

What changed

Lock and Rust suite (rust/)

  • allocator-lock.json gains bun-mimalloc, pinned to
    oven-sh/mimalloc@b20b60d959093b1bc0e24306ec72ccacb3e46fb9 (bun-dev3-v2 tip
    as of 2026-09-03), archive_sha256
    433e122220c0238ffa6f7acf21cdd059e31dd861197d8e4f553a56bef1dc85ac, MIT,
    adapter_kind: mimalloc-c-api, expected_static_library: libmimalloc.a.
    Ordered between upstream-mimalloc and mimalloc-pprof so the fork stays last.
  • No new adapter needed. Bun's public mi_* surface is upstream's, so
    native/adapter_mimalloc.c compiles against its headers unchanged — verified
    by compiling it and by the child's --adapter-smoke.
  • Build recipe is byte-for-byte the upstream-mimalloc recipe minus MI_PPROF,
    which Bun's tree does not define: Release, MI_BUILD_STATIC=ON,
    MI_BUILD_SHARED=OFF, MI_BUILD_TESTS=OFF, MI_OPT_ARCH=OFF,
    MI_OPT_SIMD=ON, -O3 -fno-omit-frame-pointer.
  • Every four-allocator assumption became five: the id arrays in
    orchestration/validate/latency/memory/scaling, the block permutation and
    near-balanced rotation, ordinal bounds, comparison-key arity, provenance
    counts, the JSON schemas, and the synthetic fixtures (scaling-raw-run.json
    regenerated via benchmark-scaling-validate --fixture-out).

Producer and dashboard (ci/)

  • build_benchmark_allocators.py builds and validates the row; the mimalloc
    option comparison now also asserts Bun's flags are exactly the upstream flags
    minus MI_PPROF, so the three mimalloc rows can never silently diverge.
  • benchmark_report.py: fifth palette colour, fifth scaling series colour,
    fifth legend row, and every remaining arity derived from ALLOCATOR_IDS. Bar
    pitches were reduced so five rows fit the existing panel geometry.

The three mimalloc rows share a recipe, not a base — docs now say so
The upstream-mimalloc row is pinned at dev3@bcee5a88, which is
MI_MALLOC_VERSION 30403 (v3.4.3), while Bun's b20b60d9 and this fork's base
6def7be9 are both 30500 (v3.5.0). Verified against the built trees:
MI_OPT_FREE_SMALL does not exist at bcee5a88 and auto-enables in both v3.5.0
trees, so those two rows compile with MI_OPT_FREE_SMALL=1 and the upstream row
does not. "Same dev3 base", "the only intended difference is MI_PPROF" and
"differ only in their source" were therefore misleading and are corrected:
Bun-vs-fork is the like-for-like line, upstream-vs-fork mixes base and fork
changes. Bumping the upstream row to the fork's own base is filed as #332.

Backwards compatibility (not in the issue, but it would have gone red)
The benchmark-stats branch still carries four-identity history rows, and
latest.json's memory/latency/scaling sections are measured on their own
schedules and carried forward onto later core envelopes. The first five-row run
would therefore have carried four-row sections into a five-row envelope and
failed. ALLOCATOR_ID_LINEAGES now lists the accepted allocator sets oldest
first — the same pattern SCALING_THREAD_POINT_LINEAGES already uses for thread
points — and the carried-pin check became a subset check: a section may carry
fewer rows than the core run, never a different pin. This suite's own pre-#325
synthetic envelope and history row are checked in under
ci/tests/fixtures/benchmark/legacy/ (latest.json.gz, 31 KB compressed from
2.4 MB — they are synthetic samples, not a copy of production data) with tests
that validate them, carry their sections onto a five-row envelope, render the
result, confirm a moved competitor pin is still rejected while a moved fork
sha is not, and confirm render refuses a core envelope recorded under the older
set.

Positive control (issue acceptance criterion)
ci/tests/test_build_benchmark_allocators.py::test_a_mis_hashed_bun_archive_fails_the_build_instead_of_being_skipped
builds a small synthetic tarball, computes its real digest, corrupts one
character of it, and asserts download_archive raises
ArchiveError("checksum mismatch") and leaves nothing on disk — then repeats
with the honest digest to prove the control failed for the hash and not for an
unrelated reason. It exercises the same download_archive the Bun row goes
through, over a local file:// URL so it needs no network; it does not
re-download the real oven-sh/mimalloc archive. Sibling tests in the same file
assert the checked-in Bun row's locked digest, pin and flags directly.

Local verification

cargo test -p benchmark-suite -p dashboard green, clippy reports no errors
(pre-existing warnings only), cargo fmt --check delta-neutral against main
(24 diffs before and after), ruff check clean, pyright 0 errors,
pytest ci/tests 312 passed, and uv run ci/verify_local.py --only rust,lint:

config | result | seconds
-------+--------+--------
rust   | PASS   | 126.3
lint   | FAIL   |  91.1

The lint row is not this branch. This checkout is shared with a concurrent
agent whose in-progress, untracked ci/tests/test_bench_hole_purging_allocators.py
is collected by pytest ci/tests and fails on fixtures it has not written yet
(FileNotFoundError: ci/tests/fixtures/allocator_idle/allocator-idle-report.json),
and whose file is also the one ruff format --check flags. Excluding that one
file: pytest ci/tests --ignore=ci/tests/test_bench_hole_purging_allocators.py
→ 312 passed, and ruff format --check ci → 45 of 46 files formatted, the
one exception being theirs. Nothing on this branch is red; I did not touch or
reformat their work.

The Bun row builds through the real lock pipeline

bazel 9.1.0 is not installed on this machine, so an orchestrated five-row run
was not possible locally.
What I did instead: drove the four buildable rows
through ci/build_benchmark_allocators.py's own functions — archive download →
SHA-256 verify → cmake-ninja → cargo build --bin benchmark-child → link-identity
check → adapter smoke. All four passed, including the new row:

library: out/bun-probe/build/bun-mimalloc/libmimalloc.a
child:   out/bun-probe/children/bun-mimalloc/benchmark-child
link identity: {"expected_allocator_symbol": "mi_malloc",
                "forbidden_allocator_symbols_absent": ["TCMallocInternalMalloc", "je_malloc"],
                "needed_libraries": ["libgcc_s.so.1", "libc.so.6", "ld-linux-x86-64.so.2"]}
smoke: {
 "allocator_id": "bun-mimalloc",
 "allocator_version": "bun-dev3-v2@b20b60d9",
 "source_sha": "b20b60d959093b1bc0e24306ec72ccacb3e46fb9",
 "library_sha256": "2064e18bb552f4f590e0e3be2ae52cb4a91b8b37fb2e20005bb2f4e0f6af1842",
 "child_binary_sha256": "2f039219e2316074e78c0fa17f4bb3e98a968549061b6f4114af4834ad910bca",
 "checksum": 16427944790028149437, "usable_size": 128
}

The three archive digests I downloaded independently matched the lockfile
exactly, including the new one.

A short paired run — functional proof only, NOT a measurement

Driving those four children with one --scaling request each, same pattern,
seed, worker count and operation count:

sparse-tiny-hot  (4 workers, 5000000 ops/worker, median of 3 paired blocks)
  identical workload checksum across allocators: True
  jemalloc                88.76 M ops/s   1.007x vs upstream
  upstream-mimalloc       88.18 M ops/s   1.000x vs upstream
  bun-mimalloc            88.01 M ops/s   0.998x vs upstream
  mimalloc-pprof          24.40 M ops/s   0.277x vs upstream

Read this as "the row runs and pairs correctly", nothing more. The
identical workload checksum: True line is the point: all four children replay
the same stream and agree on the result, so the new row is a valid participant
in a paired block. The ratios are not measurements — unpinned dev box under
its own build load, no calibration, no CPU affinity, no warmup, 3 blocks, no
bootstrap. Headline numbers come from the scheduled dashboard run.

Left to the scheduled dashboard run

  • README chart SVGs are untouched. They are regenerated by the publication
    pipeline from a real measured run; regenerating them here would mean
    publishing dev-box numbers. The next scheduled run picks up the fifth row.
  • No "honest reading" paragraph in README. The issue asks for one with
    numbers; there are no measured five-row numbers yet, so writing it now would
    be fabrication. README instead states plainly that the charts are regenerated
    by the scheduled run and a freshly added row appears there first. Worth a
    follow-up once one full run has published.

This also fixes a production outage benchmark-stats has been in for 8 days

benchmark-stats has failed every day since 2026-08-27 (latest: run
33761935520, job build-and-measure) with:

ERROR: /home/runner/work/_temp/latest.json.memory: allocator source pins differ from the core run

render carries the prior memory and latency sections forward, and
validate_latest compared every (allocator, sha) pair against the core run
— including mimalloc-pprof, whose own commit legitimately moves between the
weekly memory/latency runs and the daily stats run. The scaling path had already
solved this by filtering to LOCK_PINNED_ALLOCATORS; that filter now lives
inside validate_carried_pins so all three sections get it. Reproduced on the
fixture before and after:

before:  moved FORK sha -> FAIL (allocator source pins differ from the core run)
after:   moved FORK sha -> OK
         moved COMPETITOR sha -> still rejected

Also tightened in the opposite direction: render now requires a freshly
produced
core envelope to carry the current ALLOCATOR_IDS exactly. Lineage
tolerance is only for artifacts that were already published — carried sections,
the prior latest, history rows — so a producer that silently dropped a row
cannot publish.

Merge checklist

  1. Merge this PR (it contains the carried-pin fix above).
  2. gh workflow run benchmark-stats.yml -f mode=full — all four production
    benchmark workflows share concurrency: benchmark-stats-production with
    cancel-in-progress: false, so a manual run cannot race a cron.
  3. Watch it publish a five-row latest.json (this is issue benchmarks: add oven-sh/mimalloc (Bun's fork) as a fifth allocator row in every chart #325's "one full
    dashboard run with five rows published" acceptance criterion, and it also
    ends the 8-day outage).
  4. The weekly crons follow on their own — benchmark-scaling Sun 07:23,
    benchmark-memory/benchmark-latency Sun 08:41, all UTC. They overlay onto
    the five-row envelope from step 3.

Step 2 matters because attach_scaling_report / attach_latency_report (Rust)
require a metric report's pinned rows to exist in the base envelope's allocator
list. That guard is right and I did not loosen it: a scaling panel with a Bun
line over a core provenance table with no Bun row would be a page that cannot be
read. It just means the five-row core has to land first.

Budget check

benchmark-scaling.yml has timeout-minutes: 20 against a comment that still
quoted "~6 min sweep on top of a ~6 min fixed build" from the four-allocator
sweep. Five rows means +25% sweep and one more cargo build --release of
benchmark-child, so roughly 7.5 + 7.5 min. The comment now says that, and says
plainly that a timeout should raise the limit rather than drop a thread point or
a row. It is the tightest of the four budgets (benchmark-stats has 50,
memory/latency 60); I did not bump it speculatively.

Sentinel

benchmark-sentinel.yml runs the fork-only PR dashboard (rust/dashboard) with
no allocator matrix, so there is nothing to add to its workflow. The row
recognition the issue asks for lives in ci/benchmark_report.py —
LOCK_PINNED_ALLOCATORS now includes bun-mimalloc, and ALLOCATOR_ID_LINEAGES
governs which allocator sets a published artifact may declare. Both updated.

Things you may want to overrule

  • Legend label. The issue specifies Bun mimalloc (oven-sh @ b20b60d9).
    The pixel and SVG legends carry the compact row id bun-mimalloc, matching
    the other four rows — the full label at legend scale would not fit the SVG
    legend strip alongside upstream-mimalloc and mimalloc-pprof. The full
    label and pin live in the new docs/benchmarks.md pinned-sources table and on
    the dashboard's allocator-provenance table. Say the word and I will widen the
    legend instead.
  • ci/bench_hole_purging.py has no bun run. Feasible in principle — Bun's
    fork does carry mi_on_thread_idle and mi_purge_holes_stats_t — but the
    committed light/dark SVGs, CSV and report JSON are one measured artifact set
    produced together on the reference machine, and --check compares the
    committed SVGs. Adding a third series means re-measuring all of it there, not
    editing the renderer, so I left it and recorded the reason in
    docs/benchmarks.md.
  • An observation I did not chase (CLAUDE.md rule 7). In the probe above
    mimalloc-pprof sits at ~0.27x upstream on sparse-tiny-hot, stable across
    two different allocator orderings. Both are Release builds; the fork's differ
    only by MI_PPROF=1 and MI_OPT_FREE_SMALL=1 in its cmake defines. This is
    an uncalibrated dev-box reading and may be an artefact of the probe (no
    warmup, no affinity) rather than anything real — but it is reproducible here,
    it is nothing this PR changed, and it seemed worth surfacing rather than
    deleting.
  • Left untouched deliberately: rust/dashboard/src/main.rs:4 still says
    "four-allocator" because it quotes issue perf: publish a bounded four-allocator benchmark dashboard #171's title; and
    scaling-v1.schema.json's thread-point counts were already stale against the
    six-point sweep, so I scaled only the allocator dimension rather than fixing
    an unrelated drift here.

Note on branch contents

9849fbad fix(bench-harness): tolerate a child that exits before reading its request was pushed onto this branch by another agent while I was applying
review feedback. It is not part of #325 and I have left it alone rather than
force-push it away; my four review-fix commits sit on top of it as a
fast-forward. Reviewers should read it as a separate change that happens to
share the branch.

Closes #325

🤖 Generated with Claude Code

https://claude.ai/code/session_01YT4jVokb2gdT8ngFrH8i8S

zackees and others added 6 commits September 3, 2026 15:14
Adds `bun-mimalloc` to `allocator-lock.json`, pinned to oven-sh/mimalloc
`b20b60d959093b1bc0e24306ec72ccacb3e46fb9` (the `bun-dev3-v2` tip as of
2026-09-03) with its archive sha256. It is built by the same cmake-ninja
recipe as `upstream-mimalloc` (Release, static-only, MI_OPT_ARCH=OFF,
MI_OPT_SIMD=ON, -O3 -fno-omit-frame-pointer) so the comparison is apples
to apples; Bun's tree carries no MI_PPROF option, so that one flag is
absent rather than set to OFF, and the row's feature options record
pprof/memory-events as not-applicable.

Bun's public `mi_*` surface is upstream's, so `native/adapter_mimalloc.c`
compiles against its headers unchanged — no dedicated adapter is needed.

Everywhere the suite assumed four allocators is now five: the id arrays in
orchestration/validate/latency/memory/scaling, the block permutation and
near-balanced rotation, the ordinal bounds, the comparison-key arity, the
provenance counts, the JSON schemas, and the synthetic fixtures.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YT4jVokb2gdT8ngFrH8i8S
`build_benchmark_allocators.py` now builds `bun-mimalloc` from the lock like
any other row: the archive is checksummed before extraction, the pin is
required to stay at `bun-dev3-v2@b20b60d9`, and the mimalloc option
comparison additionally asserts that Bun's build flags are exactly the
upstream flags minus the MI_PPROF option Bun's tree does not carry. A
mis-hashed archive fails the build; it is never skipped.

`benchmark_report.py` grows a fifth palette entry, a fifth scaling series
colour, and a fifth legend row, and every remaining four-allocator
assumption (block permutations, ordinal bounds, latency matrix sizes, memory
pair completeness) is now derived from `ALLOCATOR_IDS`. Bar rows were
re-pitched so five fit the existing panel geometry.

The checked-in report fixtures gain the Bun row, and
`ci/tests/test_build_benchmark_allocators.py` adds issue #325's positive
control: flipping the locked digest makes `download_archive` raise and leaves
nothing on disk, proven against a local file:// tarball so it needs no
network.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YT4jVokb2gdT8ngFrH8i8S
Comment and input-description only; both workflows already drive the
allocator set from the lockfile.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YT4jVokb2gdT8ngFrH8i8S
Adds the pinned-sources table (row id, legend label, pin, build) to
docs/benchmarks.md, states that all three mimalloc rows share one cmake recipe
and that MI_PPROF is the only intended difference, and records the pin-bump
policy. README's Performance section names Bun's fork and says plainly that the
charts are regenerated by the scheduled dashboard run, so a freshly added row
appears there first.

Also records why the README's hole-purging chart stays an off/on measurement:
its committed SVGs, CSV and report JSON are one measured artifact set, so a
third series means re-measuring on the reference machine, not editing the
renderer.

No measured five-row numbers are claimed here; none have been produced yet.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YT4jVokb2gdT8ngFrH8i8S
Adding a fifth allocator would otherwise have turned the first published run
red twice over. The `benchmark-stats` branch still holds history rows recorded
with four allocator identities, and `latest.json`'s optional memory, latency
and scaling sections are measured on their own schedules and carried forward
onto later core envelopes -- so the first five-row throughput run would have
carried four-row sections into a five-row envelope.

`ALLOCATOR_ID_LINEAGES` now lists every accepted allocator set, oldest first,
exactly as `SCALING_THREAD_POINT_LINEAGES` already does for the thread points:
a report is checked against the set it declares, not against the current one.
The carried-pin check becomes a subset rather than an equality, so a section
may carry fewer rows than the core run but never a different pin or a row the
core run does not have -- and it now compares (allocator, source) pairs
everywhere, which also closes the "a mapping keeps only the last sample" hole
the scaling check already warned about.

The RSS timeline builds its per-allocator series from the allocators the data
actually carries, so a four-row memory section no longer raises KeyError.

Regression coverage: the pre-#325 `latest.json` and `history.jsonl` are checked
in under `ci/tests/fixtures/benchmark/legacy/`, and the new tests validate them,
carry their sections onto a five-row envelope, render the result, and confirm a
moved competitor pin is still rejected.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YT4jVokb2gdT8ngFrH8i8S
Follows the Performance section's fifth benchmark row (#325); the two lines
landed on main after that change was written.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YT4jVokb2gdT8ngFrH8i8S
zackees and others added 5 commits September 3, 2026 15:54
…quest

benchmark_rejects_partial_or_extra_child_output was flaky (7/30 locally): the
"extra" test child prints its malformed response and exits without reading
stdin, so when it beat the harness's write_all the write failed with EPIPE and
run_benchmark returned BenchError::WriteRequest instead of
InvalidChildResponse. A BrokenPipe on the request write now falls through to
the exit-status and response checks, which is what judges such a child.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QbSyYDzMo4rzrdqZz7cBmt
`history-v1.schema.json` describes what the producer emits today. Rows
published before the Bun row landed (#325) carry four identities and are still
accepted by `ci/benchmark_report.py` via `ALLOCATOR_ID_LINEAGES`; say so in the
file rather than leaving the two contracts looking contradictory.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YT4jVokb2gdT8ngFrH8i8S
…forward

`benchmark-stats` has been red for eight consecutive days (since 2026-08-27;
run 33761935520, job build-and-measure) with

    latest.json.memory: allocator source pins differ from the core run

and this is the cause. `render` carries the prior memory and latency sections
forward, then `validate_latest` compared every (allocator, source) pair against
the core run -- including `mimalloc-pprof`, whose commit legitimately moves
between the weekly memory/latency runs and the daily stats run. The scaling
path had already solved this by filtering to `LOCK_PINNED_ALLOCATORS`; that
filter now lives inside `validate_carried_pins`, so all three sections get it.

Only the lock-pinned competitors are comparable: they are the comparison
baseline, and one built from a different commit would silently change what the
chart means. The commit each section was measured at stays recorded on the
section itself, so the two halves of latest.json can never be read as one build.

Separately, lineage tolerance is now strictly for artifacts that were already
published. `render` requires a freshly produced core envelope to carry the
current allocator set exactly, so a producer that silently dropped a row cannot
publish -- the tolerance covers carried sections, the prior latest and history
rows, and nothing else.

Also colours the throughput bars by allocator identity rather than by position
in the summary list, matching `latency_png`, so a bar always carries its
allocator's legend colour.

Tests: a carried section survives the fork moving under it while a moved
competitor pin is still rejected, and `render` refuses a core envelope recorded
under the older set. The 2.4 MB synthetic legacy fixture is now stored gzipped
(31 KB) with a matching `.gitignore` exception.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YT4jVokb2gdT8ngFrH8i8S
The comment still quoted "~6 min of sweep on top of a ~6 min fixed build" from
the four-allocator sweep. Five rows add 25% of measurement and a fifth
benchmark-child build, so the note now says ~7.5 + ~7.5 min against the
20-minute limit, and says plainly that a timeout should raise the limit rather
than drop a thread point or a row. No behavior change.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YT4jVokb2gdT8ngFrH8i8S
They share a recipe, not a tree. The `upstream-mimalloc` row is pinned at
`dev3@bcee5a88`, which is MI_MALLOC_VERSION 30403 (v3.4.3), while Bun's
`b20b60d9` and this fork's base `6def7be9` are both 30500 (v3.5.0). Verified
against the built trees: `MI_OPT_FREE_SMALL` does not exist at `bcee5a88` and
auto-enables in the two v3.5.0 trees, so the Bun and fork rows compile with
`MI_OPT_FREE_SMALL=1` and the upstream row does not.

So "same dev3 base", "the only intended difference is MI_PPROF" and "differ
only in their source" were all misleading. They now say what is true: one
recipe, three trees, of which two are the same version -- which makes
Bun-vs-fork the like-for-like comparison and upstream-vs-fork a mix of base and
fork changes. Bumping the upstream row to the fork's own base is tracked in
#332.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YT4jVokb2gdT8ngFrH8i8S
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.

benchmarks: add oven-sh/mimalloc (Bun's fork) as a fifth allocator row in every chart

1 participant