Phase 70-0: Infrastructure prep for refill tuning (Observability + WarmPool Sizing)

- Observability Fix: Enabled unified cache hit/miss stats in release builds when HAKMEM_UNIFIED_CACHE_STATS_COMPILED is set.
- WarmPool Sizing: Decoupled hardcoded '12' from prefill logic; now uses TINY_WARM_POOL_DEFAULT_PER_CLASS macro and respects ENV overrides.
- Increased TINY_WARM_POOL_MAX_PER_CLASS to 32 to support wider ENV sweeps.
- Added unified_cache_auto_stats destructor to dump metrics at exit (replacing debug print hack).
This commit is contained in:
Moe Charm (CI)
2025-12-18 03:02:40 +09:00
parent b6212bbe31
commit a6ab262ad2
5 changed files with 32 additions and 26 deletions

View File

@ -266,6 +266,9 @@ sp_acquire_from_empty_scan(int class_idx, SuperSlab** ss_out, int* slab_idx_out,
SuperSlab* primary_result = NULL;
int primary_slab_idx = -1;
// Cache warm pool cap once per acquire call (SSOT: same as unified_cache_refill()).
const int warm_cap = warm_pool_max_per_class();
for (int i = 0; i < scan_limit; i++) {
SuperSlab* ss = super_reg_by_class_at(class_idx, i);
if (!(ss && ss->magic == SUPERSLAB_MAGIC)) continue;
@ -274,9 +277,8 @@ sp_acquire_from_empty_scan(int class_idx, SuperSlab** ss_out, int* slab_idx_out,
if (ss->empty_count == 0) continue; // No EMPTY slabs in this SS
// WARM POOL PREFILL: Add HOT SuperSlabs to warm pool (if not already primary result)
// This is low-cost during registry scan and avoids future expensive scans
// Phase 1: Increase threshold from 4 to 12 to match TINY_WARM_POOL_MAX_PER_CLASS
if (ss != primary_result && tiny_warm_pool_count(class_idx) < 12) {
// This is low-cost during registry scan and avoids future expensive scans.
if (ss != primary_result && tiny_warm_pool_count(class_idx) < warm_cap) {
tiny_warm_pool_push(class_idx, ss);
// Track prefilled SuperSlabs for metrics
g_warm_pool_stats[class_idx].prefilled++;