Skip to content

Add kamepoolalloc (kp) allocator#265

Open
northriv wants to merge 8 commits into
daanx:masterfrom
northriv:add-kamepoolalloc
Open

Add kamepoolalloc (kp) allocator#265
northriv wants to merge 8 commits into
daanx:masterfrom
northriv:add-kamepoolalloc

Conversation

@northriv

@northriv northriv commented Jun 11, 2026

Copy link
Copy Markdown

Add kamepoolalloc (kp) — a lock-free four-tier pool allocator (1 B .. multi-GiB: buckets / dedicated chunks / large mmap / huge) with a per-thread two-level recycle cache for the 32 KiB .. 32 MiB range. Dual-licensed Apache-2.0 OR GPL-2.0+. Production allocator of the KAME instrument-control framework since 2008; chunk-claim / recycle / orphan-chain protocols are TLA+ and GenMC (RC11) model-checked.
https://github.com/northriv/kamepoolalloc

Pinned to v1.0.2 (adds musl/Alpine support + Fedora-GCC build over v1.0.1; inherits the dylib banner gating + Linux malloc_usable_size co-interpose + word-cache default-on). Three-hunk patch only (platform.yml matrix + bench.sh + build-bench-env.sh); no README/result edits.

CI status — kp passes on all three distros. The ubuntu / fedora / alpine kp jobs all run the full suite with zero crashes (grep -c 'signal 11' = 0 in each job log; note mimalloc-bench keeps a job green even if an individual bench crashes, so the log grep is the real check). v1.0.2 specifically fixed two musl-only issues that this CI surfaced — aligned-family interception (memalign/posix_memalign/aligned_alloc, for rptest) and a TSD-teardown dangling-pointer skip in the cross-dealloc batch (for rocksdb's thread-pool join under musl __pthread_tsd_run_dtors) — plus a Fedora-GCC <cstdlib> include.

Note on the other red jobs: the failing jobs in the run (je, sn, rp, tcg, mesh, nomesh, hm on fedora; tcg on ubuntu; rp on alpine) are pre-existing upstream failures — the same set fails on master (e.g. the weekly scheduled runs), unrelated to this PR. This change touches no allocator other than kp and no platform/Docker config, so it neither introduces nor fixes those.

northriv and others added 8 commits June 11, 2026 21:01
kamepoolalloc is a lock-free four-tier pool allocator (1 B .. multi-GiB:
buckets / dedicated chunks / large mmap / huge) with a per-thread
two-level recycle cache for the 32 KiB .. 32 MiB range. Dual-licensed
Apache-2.0 OR GPL-2.0+. Production allocator of the KAME instrument-control
framework since 2008; the chunk-claim / recycle / orphan-chain protocols
are TLA+ and GenMC (RC11) model-checked.

https://github.com/northriv/kamepoolalloc

Pinned to v1.0.1 (banner gating + Linux malloc_usable_size co-interpose).
Full local-suite soak passed on glibc/x86-64 (incl. redis, sh6/sh8bench).
So CI exercises kamepoolalloc on ubuntu/alpine/fedora (the bench.sh
alloc_all registration alone is not enough — the GitHub Actions matrix
is the hardcoded driver).  glibc (ubuntu/fedora) is the soaked target;
musl (alpine) is unverified — if it fails there, a follow-up alpine
exclude with the actual error will mirror the existing per-allocator
excludes (dh/fg/gd/...).
…lude fixes)

Temporary commit-SHA pin (reverts to a v1.0.2 tag once CI is green).
495c2485 on northriv/kamepoolalloc master carries two distro fixes
surfaced by this PR's CI:
  - alpine/kp (musl) 6 h hang: strong-symbol free/malloc recursed into
    themselves (no __libc_* on musl) -> dlsym(RTLD_NEXT) real-libc bypass.
  - fedora/kp compile error 'atoi not declared': missing <cstdlib>
    (libstdc++ 14+ dropped the transitive include) -> add the includes.
ubuntu/kp already passed.  Verifies alpine/kp completes (no hang) and
fedora/kp compiles.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… <cstdlib>)

No-op commit to fire all.yml on the fork now that Actions are enabled
(all.yml is on: push; the previous version_kp pin push predated
enablement).  Squash before final PR.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
88a3007a on northriv/kamepoolalloc master adds Linux strong-symbol
interception of memalign/posix_memalign/aligned_alloc, routing them
through the pool's aligned path.  Fixes the alpine/musl rptest+rocksdb
SIGSEGV (musl implements those on top of the public malloc, so without
interception they returned pool pointers wrapped by libc bookkeeping).
Still a verification SHA pin; -> v1.0.2 tag once alpine/kp is green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
35177d74 adds the CrossDeallocBatch::flush at-teardown skip of the
owner force-walk poke — fixes the alpine/musl rocksdb db_bench SIGSEGV
at thread-pool join (musl __pthread_tsd_run_dtors frees the owner TLS
before the force_walk pointer is nullified).  Combined with the earlier
aligned-family (rptest) and reallocarray/recursion fixes, this should
take alpine/kp to signal-11=0.  Still a verification SHA pin; -> v1.0.2
once alpine/kp is confirmed crash-clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the verification SHA pin with the released tag v1.0.2 on
northriv/kamepoolalloc (== 35177d74).  v1.0.2 adds full musl/Alpine
support + Fedora-GCC build over v1.0.1.  mimalloc-bench fork CI: all
three distros (ubuntu/fedora/alpine) kp jobs are signal-11 = 0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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