Skip to content

feat: four rounds of instruction wins, a Rust GlobalAlloc fast path, 16-byte natural alignment - #40

Merged
Ttimmahlax merged 3 commits into
mainfrom
perf/curiosity-rounds
Sep 25, 2026
Merged

Ttimmahlax merged 3 commits into
mainfrom
perf/curiosity-rounds

Conversation

@Ttimmahlax

Copy link
Copy Markdown
Contributor

Four rounds of deterministic, exact-instruction work on the allocator, plus the Rust GlobalAlloc path that no instrument had measured, and a corpus harness that now proves each consumer actually built this tree.

Numbers (callgrind, exact; against 2.2.0 = c9631f4)

opscan op 2.2.0 now
cross-thread free 113.71 77.26
huge 2 MiB 689.68 293.68
big 4 KiB 121.00 92.00
mixed 110.93 92.82
calloc 107.57 93.19
posix_memalign 97.88 83.69
realloc 259.86 231.20

Allocator-only vs mimalloc on real programs: lua 0.52, perl 0.81, sqlite 0.83. Rust workloads (bench/rust-globalalloc.sh): boxed trees −21.1 %, maps −5.8 %, over-aligned realloc −27.3 %, identical checksums.

Validation

  • Windows core suites at default, debug_checks, secure, blockmap, small profile; api (also i686); ffi; --all-features workspace tests 172/0.
  • Linux suites at default, debug_checks, secure; thread-heavy tests 10× in release, 0 failures.
  • Local replay of CI: clippy -D warnings (workspace all-features and each feature), every embedded step (small profile, aligned-region, 256k, no_std, bare metal on both RISC-V targets, api no_std), wasm self-test and size ratchet (20,511 B gz, limit 20,930), semgrep and its self-test, gate self-test, unsafe census (963, each in UNSAFE.md).
  • Downstream (tools/corpus, every row verified from its Cargo.lock to build THIS tree): SpaceDB (both configs, and its published mirror), rusty_alloc_default, rusty_zstd all PASS; SpaceDB whole workspace 314/0 and rusty_zstd 194/0 with this allocator preloaded on Linux; Silesia through rzstd byte-identical to the 2.2.0 build and round-tripped through C zstd 1.5.7, Windows and Linux. rusty_maplibre still needs its documented 2.0 features = ["std"] migration; with it, 1,199/0.

Notes for review

  • Protocol change (round two): a remote free to a parked page now releases FREEING to NORMAL, as upstream does. The loom models pass, including a new one for this transition. The extended two-remote soak exceeds loom's branch budget on this change AND on main (it has never passed as written); no CI job runs it. Tracked in the LEDGER as open.
  • Includes another session's ra_small_wsize knob (default unchanged; cfg now registered) and moves two finished plans into docs/plans/finished/.
  • Known-red CI jobs on main (stress_mt in "test (all features)", cargo vet, long miri) are expected to stay red here.

🤖 Generated with Claude Code

tim-almond-house and others added 3 commits September 25, 2026 09:21
bench/wasm-speed/target/ was committed by mistake: fingerprints, lock
files and a built .wasm. It is build output, regenerated on every run.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…irror and Silesia

Two rows had been passing while testing the crates.io allocator:
rusty_zstd reaches us through the published rusty_alloc_default shim
(its 2026-09-08 PASS never built this tree), and a TMPDIR under this repo
made repoint skip every manifest. The runner now patches the shim to a
repointed local copy, refuses a work dir inside the repo, leaves
{ workspace = true } entries alone, and reads each candidate's Cargo.lock:
a registry rusty_alloc is NOT-REPOINTED, never PASS.

Adds spacedb (published mirror) to corpus.toml and tools/corpus/silesia.sh
(Silesia through rzstd: byte-identical to the published-allocator build,
round-trip through C zstd both ways).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…oc fast path, and 16-byte natural alignment

Every change was measured alone on exact callgrind counts (opscan plus
perl, sqlite, lua, python, jq, gawk and sort) and gated on the full
suites on Windows and Linux. docs/LEDGER.md has each number and each
refutation (CURIOSITY rounds one to four, DOWNSTREAM CORPUS).

Against 2.2.0 (c9631f4), opscan Ir/op: xthread 113.71 -> 77.26,
huge 689.68 -> 293.68, big 121.00 -> 92.00, mixed 110.93 -> 92.82,
calloc 107.57 -> 93.19, posix_memalign 97.88 -> 83.69,
realloc 259.86 -> 231.20. Allocator-only vs mimalloc: lua 0.52,
perl 0.81, sqlite 0.83. Rust workloads (bench/rust-globalalloc.sh):
-21.1 % boxed trees, -5.8 % maps, -27.3 % over-aligned realloc.

Allocator core:
- remote free to a parked page releases FREEING to NORMAL, as upstream
  does (MI_NO_DELAYED_FREE); single-block pages keep DELAYED
- page_extend links at least four blocks (upstream MI_MIN_EXTEND)
- span_mark skips interior slices that already point to their start
- the medium arm pops before it collects; OOM retry only on fallible
  exits; realloc decides a move in one compare; frameless free_general;
  huge_alloc out of line; u8 zero flag in the generic chain
- options: no allocation at start-up (prim::getenv), and one walk of
  environ on Linux instead of 76 getenv calls
- huge blocks report the request rounded to a slice as usable size
- malloc_aligned_pow2 (new, #[inline]) for callers that proved the
  alignment: posix_memalign, GlobalAlloc, C++ aligned new
- ra_small_wsize knob (default unchanged) for 32-bit targets

rusty_alloc-api:
- GlobalAlloc methods are #[inline]; dealloc is the inline free
- alignment up to two words served from the natural size classes
- realloc keeps a block in place at any alignment when it fits

Tests: options_env, natural_align, reentrancy. Unsafe census 947 -> 963,
every site in UNSAFE.md. Downstream: SpaceDB and rusty_zstd full suites,
Silesia byte-identical against the 2.2.0 build.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Ttimmahlax
Ttimmahlax merged commit 3374bba into main Sep 25, 2026
8 of 12 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