Tiny: Enable P0 batch refill by default + docs and task update
Summary - Default P0 ON: Build-time HAKMEM_TINY_P0_BATCH_REFILL=1 remains; runtime gate now defaults to ON (HAKMEM_TINY_P0_ENABLE unset or not '0'). Kill switch preserved via HAKMEM_TINY_P0_DISABLE=1. - Fix critical bug: After freelist→SLL batch splice, increment TinySlabMeta::used by 'from_freelist' to mirror non-P0 behavior (prevents under-accounting and follow-on carve invariants from breaking). - Add low-overhead A/B toggles for triage: HAKMEM_TINY_P0_NO_DRAIN (skip remote drain), HAKMEM_TINY_P0_LOG (emit [P0_COUNTER_OK/MISMATCH] based on total_active_blocks delta). - Keep linear carve fail-fast guards across simple/general/TLS-bump paths. Perf (1T, 100k×256B) - P0 OFF: ~2.73M ops/s (stable) - P0 ON (no drain): ~2.45M ops/s - P0 ON (normal drain): ~2.76M ops/s (fastest) Known - Rare [P0_COUNTER_MISMATCH] warnings persist (non-fatal). Continue auditing active/used balance around batch freelist splice and remote drain splice. Docs - Add docs/TINY_P0_BATCH_REFILL.md (runtime switches, behavior, perf notes). - Update CURRENT_TASK.md with Tiny P0 status (default ON) and next steps.
This commit is contained in:
@ -66,7 +66,12 @@ extern __thread void* g_tls_sll_head[TINY_NUM_CLASSES];
|
||||
extern __thread uint32_t g_tls_sll_count[TINY_NUM_CLASSES];
|
||||
|
||||
// External backend functions
|
||||
// P0 Fix: Use appropriate refill function based on P0 status
|
||||
#if HAKMEM_TINY_P0_BATCH_REFILL
|
||||
extern int sll_refill_batch_from_ss(int class_idx, int max_take);
|
||||
#else
|
||||
extern int sll_refill_small_from_ss(int class_idx, int max_take);
|
||||
#endif
|
||||
extern void* hak_tiny_alloc_slow(size_t size, int class_idx);
|
||||
extern int hak_tiny_size_to_class(size_t size);
|
||||
extern int tiny_refill_failfast_level(void);
|
||||
@ -374,8 +379,12 @@ static inline int tiny_alloc_fast_refill(int class_idx) {
|
||||
|
||||
// Box Boundary: Delegate to Backend (Box 3: SuperSlab)
|
||||
// This gives us ACE, Learning layer, L25 integration for free!
|
||||
// Note: g_rf_hit_slab counter is incremented inside sll_refill_small_from_ss()
|
||||
// P0 Fix: Use appropriate refill function based on P0 status
|
||||
#if HAKMEM_TINY_P0_BATCH_REFILL
|
||||
int refilled = sll_refill_batch_from_ss(class_idx, cnt);
|
||||
#else
|
||||
int refilled = sll_refill_small_from_ss(class_idx, cnt);
|
||||
#endif
|
||||
|
||||
// Lightweight adaptation: if refills keep happening, increase per-class refill.
|
||||
// Focus on class 7 (1024B) to reduce mmap/refill frequency under Tiny-heavy loads.
|
||||
|
||||
Reference in New Issue
Block a user