Files
hakmem/core/box/tiny_static_route_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

41 lines
1.5 KiB
C

// tiny_static_route_box.h - Static routing table for policy_snapshot bypass (Phase 3 C3)
// Eliminates per-malloc policy_snapshot + learner evaluation overhead
// ENV gate: HAKMEM_TINY_STATIC_ROUTE=0/1 (default 0)
#pragma once
#include <stdatomic.h>
#include "smallobject_policy_v7_box.h"
typedef struct {
// 0: uninit/disabled, -1: initializing, 1: ready
atomic_int inited;
SmallRouteKind route_kind[8]; // C0-C7 static route (determined at init, no learner update)
} TinyStaticRoute;
extern TinyStaticRoute g_tiny_static_route;
// Hot-path helper: true when static route table is ready (enabled + initialized).
static inline int tiny_static_route_ready_fast(void) {
return atomic_load_explicit(&g_tiny_static_route.inited, memory_order_acquire) == 1;
}
// Hot-path helper: fetch route kind when tiny_static_route_ready_fast()==true.
static inline SmallRouteKind tiny_static_route_get_kind_fast(int class_idx) {
return g_tiny_static_route.route_kind[(unsigned)class_idx & 7u];
}
// Initialize static route table (called once, at library load time)
// Returns 1 if static routing is enabled and initialized, 0 otherwise
int tiny_static_route_init_once(void);
// Get static route for class_idx.
// Returns SMALL_ROUTE_LEGACY when disabled/uninitialized/invalid (safe fallback).
SmallRouteKind tiny_static_route_get_kind(int class_idx);
// Refresh from ENV (for bench_apply_profile() sync)
void tiny_static_route_refresh_from_env(void);
// Check if static routing is enabled (cached ENV value)
int tiny_static_route_enabled(void);