Files
hakmem/core/box/tiny_env_box.h
Moe Charm (CI) d54893ea1d Phase 3 C3: Static Routing A/B Test ADOPT (+2.20% Mixed gain)
Step 2 & 3 Complete:
- A/B test (Mixed 10-run): STATIC_ROUTE=0 (38.91M) → =1 (39.77M) = +2.20% avg
  - Median gain: +1.98%
  - Result:  GO (exceeds +1.0% threshold)

- Decision:  ADOPT into MIXED_TINYV3_C7_SAFE preset
  - bench_profile.h line 77: HAKMEM_TINY_STATIC_ROUTE=1 default
  - Learner auto-disables static route when HAKMEM_SMALL_LEARNER_V7_ENABLED=1

Implementation Summary:
- core/box/tiny_static_route_box.{h,c}: Research box (Step 1A)
- core/front/malloc_tiny_fast.h: Route lookup integration (Step 1B, lines 249-256)
- core/bench_profile.h: Bench sync + preset adoption

Cumulative Phase 2-3 Gains:
- B3 (Routing shape): +2.89%
- B4 (Wrapper split): +1.47%
- C3 (Static routing): +2.20%
- Total: ~6.8% (35.2M → ~39.8M ops/s)

Next: Phase 3 C1 (TLS Prefetch, expected +2-4%)

🤖 Generated with Claude Code

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-13 18:46:11 +09:00

58 lines
3.0 KiB
C

// tiny_env_box.h - Centralized Tiny env cache (hot-path safe)
#pragma once
#include <stdatomic.h>
typedef struct {
int inited;
int tiny_tls_sll; // HAKMEM_TINY_TLS_SLL (default: 1)
int sll_multiplier; // HAKMEM_SLL_MULTIPLIER (default: 2)
int tiny_no_front_cache; // HAKMEM_TINY_NO_FRONT_CACHE (default: 0)
int tiny_no_quick; // HAKMEM_TINY_NO_QUICK (default: 0)
int tiny_prefetch; // HAKMEM_TINY_PREFETCH (default: 0)
int front_direct; // HAKMEM_TINY_FRONT_DIRECT (default: 0)
int use_class_map; // !HAKMEM_TINY_NO_CLASS_MAP (default: 1)
int route_enable; // HAKMEM_ROUTE (default: 0)
int route_sample_lg; // HAKMEM_ROUTE_SAMPLE_LG (default: 10 -> 1/1024)
int larson_fix; // HAKMEM_TINY_LARSON_FIX (default: 0)
int active_track; // HAKMEM_TINY_ACTIVE_TRACK (default: 0)
int drain_to_sll; // HAKMEM_TINY_DRAIN_TO_SLL (default: 0)
int free_to_ss; // HAKMEM_TINY_FREE_TO_SS (default: 0)
int route_free; // HAKMEM_TINY_ROUTE_FREE (default: 0)
int sll_diag; // HAKMEM_TINY_SLL_DIAG (default: 0)
int sll_safeheader; // HAKMEM_TINY_SLL_SAFEHEADER (default: 0)
int sll_ring; // HAKMEM_TINY_SLL_RING (default: 0)
int free_fast; // HAKMEM_TINY_FREE_FAST (default: 1)
int sll_canary_fast; // HAKMEM_TINY_SLL_CANARY_FAST (default: 0)
int ss_free_debug; // HAKMEM_SS_FREE_DEBUG (default: 0)
int ss_adopt; // HAKMEM_TINY_SS_ADOPT (default: 1)
int disable_remote; // HAKMEM_TINY_DISABLE_REMOTE (default: 0)
int freelist_mask; // HAKMEM_TINY_FREELIST_MASK (default: 0)
int alloc_1024_metric; // HAKMEM_TINY_ALLOC_1024_METRIC (default: 0)
int tiny_profile; // HAKMEM_TINY_PROFILE (default: 0)
int tiny_fast_stats; // HAKMEM_TINY_FAST_STATS (default: 0)
int heap_v2_stats; // HAKMEM_TINY_HEAP_V2_STATS (default: 0)
int front_slim; // HAKMEM_TINY_FRONT_SLIM (default: 0)
int sfc_cascade_pct; // HAKMEM_SFC_CASCADE_PCT (default: 50)
int sfc_cascade; // HAKMEM_TINY_SFC_CASCADE (default: 0)
int alloc_remote_relax; // HAKMEM_TINY_ALLOC_REMOTE_RELAX (default: 0)
int ss_empty_reuse; // HAKMEM_SS_EMPTY_REUSE (default: 1)
int ss_empty_scan_limit; // HAKMEM_SS_EMPTY_SCAN_LIMIT (default: 32)
int ss_acquire_debug; // HAKMEM_SS_ACQUIRE_DEBUG (default: 0)
int tension_drain_enable; // HAKMEM_TINY_TENSION_DRAIN_ENABLE (default: 1)
int tension_drain_threshold; // HAKMEM_TINY_TENSION_DRAIN_THRESHOLD (default: 1024)
int alloc_route_shape; // HAKMEM_TINY_ALLOC_ROUTE_SHAPE (default: 0)
} tiny_env_cfg_t;
extern tiny_env_cfg_t g_tiny_env;
void tiny_env_init_once(void);
static inline const tiny_env_cfg_t* tiny_env_cfg(void) {
if (__builtin_expect(!g_tiny_env.inited, 0)) {
tiny_env_init_once();
}
return &g_tiny_env;
}