Refactor: Clean up SuperSlab shared pool code
- Removed unused/disabled L0 cache implementation from core/hakmem_shared_pool.c. - Deleted stale backup file core/hakmem_tiny_superslab.c.bak. - Removed untracked and obsolete shared_pool source files.
This commit is contained in:
@ -172,42 +172,6 @@ static inline uint32_t sp_class_active_limit(int class_idx) {
|
||||
return (uint32_t)pol->tiny_cap[class_idx];
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Superslab L0 Cache (per-thread, per-class hot slot)
|
||||
// ============================================================================
|
||||
//
|
||||
// Goal:
|
||||
// - Avoid calling shared_pool_acquire_slab()'s full 3-stage logic on every
|
||||
// allocation when the same (ss, slab_idx) still has room.
|
||||
// - Keep Box boundaries: slot ownership/state is still managed by SP-SLOT,
|
||||
// L0 では「既に ACTIVE な slot を再利用するだけ」(UNUSED/EMPTY には触れない)。
|
||||
//
|
||||
// Design:
|
||||
// - Per-thread TLS for each tiny class (0..TINY_NUM_CLASSES_SS-1):
|
||||
// - SharedSSMeta* meta
|
||||
// - uint8_t slot_idx
|
||||
// - Stage 0 in shared_pool_acquire_slab():
|
||||
// - If L0 entry exists and meta->ss is non-NULL and
|
||||
// ss->slabs[slot_idx] is still bound to this class,
|
||||
// return (ss, slot_idx) directly without touching locks or lists.
|
||||
// - If SuperSlab has been freed (meta->ss == NULL) or slot reused,
|
||||
// L0 エントリを破棄して通常の Stage 1-3 にフォールバック。
|
||||
//
|
||||
// Env:
|
||||
// - HAKMEM_SS_L0=0 → L0 無効
|
||||
// - HAKMEM_SS_L0=1 → L0 有効(デフォルト)
|
||||
|
||||
static __thread SharedSSMeta* g_sp_l0_meta[TINY_NUM_CLASSES_SS];
|
||||
static __thread uint8_t g_sp_l0_slot[TINY_NUM_CLASSES_SS];
|
||||
|
||||
// NOTE: L0 は実験段階のため、現行ビルドでは常に無効化したままにする。
|
||||
// 将来の安定版で再度有効化する場合は、実装と検証をやり直すこと。
|
||||
static inline int sp_l0_enabled(void) {
|
||||
(void)g_sp_l0_meta;
|
||||
(void)g_sp_l0_slot;
|
||||
return 0; // Disabled for now
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// P0-4: Lock-Free Free Slot List - Node Pool
|
||||
// ============================================================================
|
||||
@ -932,42 +896,6 @@ shared_pool_acquire_slab(int class_idx, SuperSlab** ss_out, int* slab_idx_out)
|
||||
#endif
|
||||
sp_stage_stats_init();
|
||||
|
||||
// ========== Stage 0: Per-thread hot slot (L0) reuse ==========
|
||||
//
|
||||
// 既に ACTIVE な slot で、かつ class_idx が一致し、まだ capacity に余裕がある場合のみ
|
||||
// そのまま (ss, slab_idx) を返す。slot state の遷移や lock は一切触らない。
|
||||
if (sp_l0_enabled()) {
|
||||
SharedSSMeta* meta = g_sp_l0_meta[class_idx];
|
||||
int l0_idx = (int)g_sp_l0_slot[class_idx];
|
||||
if (meta && l0_idx >= 0) {
|
||||
SuperSlab* ss = atomic_load_explicit(&meta->ss, memory_order_acquire);
|
||||
if (ss && l0_idx < ss_slabs_capacity(ss)) {
|
||||
TinySlabMeta* slab_meta = &ss->slabs[l0_idx];
|
||||
if (slab_meta->class_idx == (uint8_t)class_idx &&
|
||||
slab_meta->capacity > 0 &&
|
||||
slab_meta->used < slab_meta->capacity) {
|
||||
sp_fix_geometry_if_needed(ss, l0_idx, class_idx);
|
||||
#if !HAKMEM_BUILD_RELEASE
|
||||
if (dbg_acquire == 1) {
|
||||
fprintf(stderr,
|
||||
"[SP_ACQUIRE_STAGE0_L0] class=%d reuse hot slot (ss=%p slab=%d used=%u cap=%u)\n",
|
||||
class_idx,
|
||||
(void*)ss,
|
||||
l0_idx,
|
||||
(unsigned)slab_meta->used,
|
||||
(unsigned)slab_meta->capacity);
|
||||
}
|
||||
#endif
|
||||
*ss_out = ss;
|
||||
*slab_idx_out = l0_idx;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
// 熱スロットが無効になっているのでクリアして通常経路へ
|
||||
g_sp_l0_meta[class_idx] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
stage1_retry_after_tension_drain:
|
||||
// ========== Stage 0.5 (Phase 12-1.1): EMPTY slab direct scan ==========
|
||||
// Scan existing SuperSlabs for EMPTY slabs (highest reuse priority) to
|
||||
@ -1043,12 +971,6 @@ stage1_retry_after_tension_drain:
|
||||
// Update hint
|
||||
g_shared_pool.class_hints[class_idx] = ss;
|
||||
|
||||
// Update per-thread hot slot (L0)
|
||||
if (sp_l0_enabled()) {
|
||||
g_sp_l0_meta[class_idx] = reuse_meta;
|
||||
g_sp_l0_slot[class_idx] = (uint8_t)reuse_slot_idx;
|
||||
}
|
||||
|
||||
*ss_out = ss;
|
||||
*slab_idx_out = reuse_slot_idx;
|
||||
|
||||
@ -1124,12 +1046,6 @@ stage2_fallback:
|
||||
// Update hint
|
||||
g_shared_pool.class_hints[class_idx] = ss;
|
||||
|
||||
// Update per-thread hot slot (L0)
|
||||
if (sp_l0_enabled()) {
|
||||
g_sp_l0_meta[class_idx] = meta;
|
||||
g_sp_l0_slot[class_idx] = (uint8_t)claimed_idx;
|
||||
}
|
||||
|
||||
*ss_out = ss;
|
||||
*slab_idx_out = claimed_idx;
|
||||
sp_fix_geometry_if_needed(ss, claimed_idx, class_idx);
|
||||
@ -1316,12 +1232,6 @@ stage2_fallback:
|
||||
// Update hint
|
||||
g_shared_pool.class_hints[class_idx] = new_ss;
|
||||
|
||||
// Update per-thread hot slot (L0)
|
||||
if (sp_l0_enabled()) {
|
||||
g_sp_l0_meta[class_idx] = new_meta;
|
||||
g_sp_l0_slot[class_idx] = (uint8_t)first_slot;
|
||||
}
|
||||
|
||||
*ss_out = new_ss;
|
||||
*slab_idx_out = first_slot;
|
||||
sp_fix_geometry_if_needed(new_ss, first_slot, class_idx);
|
||||
|
||||
Reference in New Issue
Block a user