Skip to content

perf: vein census 3 -- nine deterministic wins from real-program profiles - #51

Merged
Ttimmahlax merged 2 commits into
mainfrom
perf/vein-census-3
Oct 8, 2026
Merged

Ttimmahlax merged 2 commits into
mainfrom
perf/vein-census-3

Conversation

@Ttimmahlax

Copy link
Copy Markdown
Contributor

Census by function on real programs (perl, sqlite, lua, python, Endless Sky start-up) and the Rust GlobalAlloc workloads, then each vein probed, measured paired in one session, and kept or refuted. Full table: docs/opps.md → "Vein census 3".

Allocator instructions vs 2.2.5 (callgrind, outputs identical)

program 2.2.5 this PR Δ
Endless Sky start-up 57,380,635 53,453,604 −6.85 %
lua 23,149,581 22,632,842 −2.23 %
perl 24,668,474 24,262,947 −1.64 %
sqlite 4,592,621 4,587,503 −0.11 %

Rust whole-program: overaligned −4.24 %, threads −1.53 %, maps −0.36 %, trees flat. Peak RSS within ±0.4 %.

Landed: geometric page-extension batches (the biggest); owner-first test order for the C free/operator delete exports, with Rust's dealloc keeping the 2.2.5 order (split body, two symbols); one inlined malloc in GlobalAlloc::alloc; a small-size bin table; a typed OOM handler for operator new (frame 12 → 7); single page resolution in a moving realloc; an 8-slot heap-box cache (no mmap/munmap per thread); #[inline] usable_size; a sub/setle arm for MSVC + panic = "unwind" (still 0 callbr).

Known trade: a same-thread free into a slow page (large span, huge, aligned, full) pays the owner compare first: +2 Ir on opscan's 2 MiB (142 → 144) and 64 MiB (834 → 836) ops.

Refuted and recorded: a fixed 8 KiB batch (thread life +10 %), three other shapes of the alloc split, two other shapes of the remote arm, and the thread-exit collect (inherent).

Validated: workspace --all-features 177/177, linux-gates 42/0, embedded 15/15, clippy Windows + Linux, fmt, semgrep, wasm self-test + size, gate self-test, miri gate + openheimer 37/37, mimalloc-bench 19/19, churn 5/5, real-world programs identical across ra/mi/sys, alloc-eval (8 traces), rusty_sloth --release --features cuda with crates.io identity. New public items: alloc::malloc_or_with, alloc::OnOom, alloc::free_inline_flags_first (additive). Unsafe census 981 → 994, each in UNSAFE.md.

🤖 Generated with Claude Code

tim-almond-house and others added 2 commits October 7, 2026 23:17
…iles

Census by function on real programs (perl, sqlite, lua, python, Endless Sky
start-up) and the Rust GlobalAlloc workloads; docs/opps.md "Vein census 3".
Allocator Ir vs 2.2.5, outputs identical: Endless Sky -6.85 %, lua -2.23 %,
perl -1.64 %, sqlite -0.11 %; Rust overaligned -4.24 %, threads -1.53 %,
maps -0.36 %. Peak RSS within +-0.4 %.

1. page_extend carves in geometric batches (at least what the page holds):
   the slow-path trips, not the 2.75 Ir/block linking, were the cost.
   ES -4.50 %. A fixed 8 KiB batch cost thread life +10 % (refuted).
2. C exports test the owner before the page flags, so a cross-thread free
   into a FULL page goes straight to remote_free (ES -515 k, xthread -2.9 %).
   Rust's dealloc keeps the 2.2.5 order (free_inline_flags_first): the
   bigger remote arm stopped __rust_dealloc inlining into drop glue
   (trees +2.88 %). Trade: a local free into a slow page +2 Ir.
3. GlobalAlloc::alloc: only the natural-alignment arm out of line (it was a
   second inlined malloc copy). maps -0.33 %, overaligned -1.81 %.
4. SMALL_BIN table for the generic path's bin, by the word count it already
   computes. ES -0.70 % and more.
5. malloc_or_with::<H: OnOom>: operator new's cold arm frame 12 -> 7.
   ES -419 k.
6. realloc_live hands its resolved page to the free (lua -60 k).
7. An 8-slot heap-box cache (upstream TD_CACHE_SIZE): no mmap/munmap pair
   per thread. Thread life -1.1 %, minor faults -15 %.
8. #[inline] usable_size: over-aligned Rust realloc -2.06 %.
9. MSVC + panic=unwind: sub/setle into an output operand, +2 over the goto
   where 2.2.5's plain decrement was +3. Still 0 callbr there.
10. Thread-exit collect: refuted as inherent (the cross-thread drain).

Gates: workspace --all-features 177/177, linux-gates 42/0, embedded 15/15,
clippy (Windows + Linux), fmt, semgrep, wasm self-test + size, gate
self-test, miri gate + openheimer 37/37, mimalloc-bench 19/19, churn 5/5,
real-world outputs identical across ra/mi/sys, alloc-eval 8 traces,
rusty_sloth built with crates.io identity (--release --features cuda).
Unsafe census 981 -> 994 (UNSAFE.md).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cargo fmt rewrote init.rs (the repo's one CRLF file) to LF in the previous
commit, which buried its 52-line change in a 2,547-line diff. Restored;
cargo fmt --check accepts either.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Ttimmahlax
Ttimmahlax merged commit 4f296a7 into main Oct 8, 2026
13 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.

2 participants