2.7 KiB
2.7 KiB
Current Task: Phase 9-2 Refactoring (Complete) & Phase 10 Preparation
Date: 2025-12-01 Status: COMPLETE (Phase 9-2) / PLANNING (Phase 10) Goal: Legacy Backend Removal, Shared Pool Unification, and Type Safety
Phase 9-2 Achievements (Completed)
-
Legacy Backend Removal & Unification (2025-12-01)
- Eliminated Fallback: Removed
hak_tiny_alloc_superslab_backend_legacyfallback. Shared Pool is now the sole backend (hak_tiny_alloc_superslab_box->hak_tiny_alloc_superslab_backend_shared). - Soft Cap Removed: Removed the artificial "Soft Cap" limit in Shared Pool Stage 3, allowing it to handle full workload load.
- EMPTY Recycling: Implemented
SLAB_TRY_RECYCLEwith atomic batch decrement ofmeta->usedin_ss_remote_drain_to_freelist_unsafe. This ensures EMPTY slabs are immediately returned to the global pool. - Race Condition Fix: Moved
remove_superslab_from_legacy_head(ss)to the start ofshared_pool_release_slabto prevent Legacy Backend from allocating from a slab being recycled. Addedtotal_active_blockscheck before freeing. - Performance: 50.3 M ops/s in WS8192 benchmark (vs 16.5 M baseline). OOM/Crash issues resolved.
- Eliminated Fallback: Removed
-
Critical Fixes (Deadlock & OOM)
- Deadlock:
shared_pool_acquire_slabreleasesalloc_lockbeforesuperslab_allocate. - Is Empty Return:
tiny_free_local_boxnow returnsint is_emptystatus to allow safe, race-free recycling by the caller.
- Deadlock:
-
Code Refactoring
- Modularized
hakmem_shared_pool.cintoacquire/release/internalcomponents.
- Modularized
Next Phase: Phase 10 - Type Safety & Hardening
1. Pointer Type Safety (Debug Only)
- Issue: Occasional
[TLS_SLL_HDR_RESET]warnings indicate confusion betweenBasePtr(header start) andUserPtr(payload start). - Solution: Implement "Phantom Type" checking macros enabled only in debug builds.
- Define
hak_base_ptr_tandhak_user_ptr_tstructs in debug. - Define strict conversion macros (
hak_base_to_user,hak_user_to_base). - Apply incrementally to
tls_sll_box,free_local_box, andremote_free_box. - Goal: Catch pointer arithmetic errors at compile time in debug mode.
- Define
2. Header Protection Hardening
- Goal: Reinforce header integrity checks in
tiny_free_local_boxandtls_sll_popusing the new type system.
3. Fast Path Optimization
- Goal: Re-evaluate hot path performance (Stage 1 lock-free) after Phase 9-2 stabilization.
Current Status
- Build: Passing (Clean build verified).
- Benchmarks:
- WS8192: 50.3 M ops/s (Shared Pool ONLY).
- Crash/OOM: Resolved.
- Pending: Phase 10 implementation (Type Safety).