Major Features: - Debug counter infrastructure for Refill Stage tracking - Free Pipeline counters (ss_local, ss_remote, tls_sll) - Diagnostic counters for early return analysis - Unified larson.sh benchmark runner with profiles - Phase 6-3 regression analysis documentation Bug Fixes: - Fix SuperSlab disabled by default (HAKMEM_TINY_USE_SUPERSLAB) - Fix profile variable naming consistency - Add .gitignore patterns for large files Performance: - Phase 6-3: 4.79 M ops/s (has OOM risk) - With SuperSlab: 3.13 M ops/s (+19% improvement) This is a clean repository without large log files. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
3.0 KiB
3.0 KiB
SlabHandle Box (Ownership + Remote Drain + Metadata)
目的
- Slab 単位の操作を「所有権を持つハンドル」でカプセル化し、境界の 1 箇所化と不変条件の自動チェックを実現する。
- 下層(RemoteQueue / Ownership)の堅牢性を高め、上層(Publish/Adopt)が壊れない土台を作る。
ファイル
- core/slab_handle.h(約 100 行)
型
SlabHandle { ss, meta, slab_idx, owner_tid, valid }valid==1のときのみ drain/modify が可能。
API
slab_try_acquire(ss, idx, tid) -> SlabHandleowner_tid==0の場合のみ CAS で取得し、valid=1のハンドルを返す。
slab_drain_remote(&h)valid==1必須。RemoteQueue → freelist へ統合。remote_countsを 0 に。
slab_release(&h)owner_tid=0に戻し、valid=0にする(明示的に解放したい場合)。
- アクセサ:
slab_meta(&h),slab_freelist(&h),slab_used(&h),slab_capacity(&h),slab_is_valid(&h) - 便宜操作:
slab_freelist_push(&h, ptr),slab_freelist_pop(&h)(いずれもvalid==1必須)
不変条件(Invariants)
- RemoteQueue(Box 2)は push/exchange と
remote_countsの整合のみ扱い、owner/freelist には触れない。 - Ownership(Box 3)は
owner_tid==0からの取得と release のみ扱い、RemoteQueue には触れない。 - Refill 採用境界 1 箇所でのみ
drain → bind → owner_acquireを行う。
適用箇所(6 箇所)
tiny_refill.h: Sticky / Hot / Bench / Mailbox 採用分岐tiny_mmap_gate.h: Registry scan 採用hakmem_tiny_free.inc: SuperSlab adopt path
アンチパターンの禁止(Do/Don’t)
- Don’t: publish 側で drain / owner を弄る(通知とヒントのみに限定)。
- Don’t: RemoteQueue が freelist/owner に触る。
- Do: 採用境界でのみ
slab_try_acquire→slab_drain_remote→bindの順で処理。
デバッグ TIPS
HAKMEM_SAFE_FREE=1: free 境界での範囲/クラス不一致の Fail‑Fast。HAKMEM_TINY_TRACE_RING=1 + SIGUSR2:remote_push/remote_drain/mailbox_publish/mailbox_fetch/bindを確認。HAKMEM_TINY_RF_FORCE_NOTIFY=1: 初回通知の見逃しが疑われるケースの可視化。
既知の現象(追跡中)
fault_addr=0x6261、free_enterが同一ptrで異なるclassに跨って記録されるケースがある。- 読み: free 境界のクラス判定(lookup)または直前の bind/owner の不整合。
- 対処: 上記 Fail‑Fast を既定 ON(デバッグ期間)、Ring の直前イベントで境界のどこでズレたかを特定。
関連修正(所有権なし drain の是正)
hakmem_tiny_superslab.h:376付近:ss_remote_drain_light()が所有権チェックなしで drain していた問題を修正。- 修正方針:
ss_owner_try_acquire()成功時にのみss_remote_drain_to_freelist()を実行(Box 3→2 の順)。