- Split core/hakmem_shared_pool.c into acquire/release modules for maintainability. - Introduced core/hakmem_shared_pool_internal.h for shared internal API. - Fixed incorrect function name usage (superslab_alloc -> superslab_allocate). - Increased SUPER_REG_SIZE to 1M to support large working sets (Phase 9-2 fix). - Updated Makefile. - Verified with benchmarks.
3.0 KiB
3.0 KiB
Current Task: Phase 9-2 Refactoring (Complete)
Date: 2025-11-30 Status: COMPLETE (Phase 9-2 & Refactoring) Goal: SuperSlab Unified Management, Stability Fixes, and Code Refactoring
Phase 9-2 Achievements (Completed)
-
Critical Fixes (Deadlock & OOM)
- Deadlock:
shared_pool_acquire_slabnow releasesalloc_lockbefore callingsuperslab_allocate(viasp_internal_allocate_superslab), preventing lock inversion withg_super_reg_lock. - OOM: Enabled
HAKMEM_TINY_USE_SUPERSLAB=1by default inhakmem_build_flags.h, ensuring fallback to Legacy Backend when Shared Pool hits soft cap.
- Deadlock:
-
SuperSlab Management Unification
- Unified Entry:
sp_internal_allocate_superslabhelper introduced to manage safe allocation flow. - Unified Free:
remove_superslab_from_legacy_headimplemented to safely remove pointers from legacy lists when freeing via Shared Pool.
- Unified Entry:
-
Code Refactoring (Split
hakmem_shared_pool.c)- Split Strategy: Divided the monolithic
core/hakmem_shared_pool.c(1400+ lines) into logical modules:core/hakmem_shared_pool.c: Initialization, stats, and common helpers.core/hakmem_shared_pool_acquire.c: Allocation logic (shared_pool_acquire_slaband Stage 0.5-3).core/hakmem_shared_pool_release.c: Deallocation logic (shared_pool_release_slab).core/hakmem_shared_pool_internal.h: Internal shared definitions and prototypes.
- Makefile: Updated to compile and link the new files.
- Cleanups: Removed unused "L0 Cache" experimental code and fixed incorrect function names (
superslab_alloc->superslab_allocate).
- Split Strategy: Divided the monolithic
Next Phase Candidates (Handover from Phase 9-2)
1. Soft Cap (Policy) Tuning
- Issue: Medium Working Sets (8192) hit the Shared Pool "Soft Cap" easily, causing frequent fallbacks and performance degradation.
- Action: Review
hakmem_policy.cand adjusttiny_capor improve dynamic adjustment logic.
2. Fast Path Optimization
- Issue: Small Working Sets (256) show 70-88% performance vs SysAlloc due to lock/call overhead. Refactoring caused a slight dip (15%), highlighting the need for optimization.
- Action: Re-implement a lightweight L0 Cache or optimize the lock-free path in Shared Pool for hot-path performance. Consider inlining hot helpers again via header-only implementations if needed.
3. Legacy Backend Removal
- Issue: Legacy Backend (
g_superslab_heads) is still kept for fallback but causes complexity. - Action: Plan complete removal of
g_superslab_heads, migrating all management to Shared Pool.
Current Status
- Build: Passing (Clean build verified).
- Benchmarks:
HAKMEM_TINY_SS_SHARED=1(Normal): ~20.0 M ops/s (working, fallback active).HAKMEM_TINY_SS_SHARED=2(Strict): ~20.3 M ops/s (working, OOMs on soft cap as expected).
- Pending: Selection of next focus area.