Phase 7-Step3: Add config box integration for dead code elimination
**What Changed**:
- Include tiny_front_config_box.h in tiny_alloc_fast.inc.h (line 25)
- Add wrapper functions tiny_fastcache_enabled() and sfc_cascade_enabled() (lines 33-41)
**Why This Works**:
The config box provides dual-mode operation:
- Normal mode: Macros expand to runtime function calls (e.g., TINY_FRONT_FASTCACHE_ENABLED → tiny_fastcache_enabled())
- PGO mode (-DHAKMEM_TINY_FRONT_PGO=1): Macros become compile-time constants (e.g., TINY_FRONT_FASTCACHE_ENABLED → 0)
**Wrapper Functions**:
```c
static inline int tiny_fastcache_enabled(void) {
extern int g_fastcache_enable;
return g_fastcache_enable;
}
static inline int sfc_cascade_enabled(void) {
extern int g_sfc_enabled;
return g_sfc_enabled;
}
```
**Performance**:
- bench_random_mixed (ws=256): 80.6 M ops/s (maintained, no regression)
- Baseline: Phase 7-Step2 was 80.3 M ops/s (-0.37% within noise)
**Next Steps** (Future Work):
To achieve actual dead code elimination benefits (+5-10% expected):
1. Replace g_fastcache_enable checks → TINY_FRONT_FASTCACHE_ENABLED macro
2. Replace tiny_heap_v2_enabled() calls → TINY_FRONT_HEAP_V2_ENABLED macro
3. Replace ultra_slim_mode_enabled() calls → TINY_FRONT_ULTRA_SLIM_ENABLED macro
4. Compile entire library with -DHAKMEM_TINY_FRONT_PGO=1 (not just bench)
**Files Modified**:
- core/tiny_alloc_fast.inc.h (+16 lines)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -22,10 +22,23 @@
|
|||||||
#include "tiny_adaptive_sizing.h" // Phase 2b: Adaptive sizing
|
#include "tiny_adaptive_sizing.h" // Phase 2b: Adaptive sizing
|
||||||
#include "box/tls_sll_box.h" // Box TLS-SLL: C7-safe push/pop/splice
|
#include "box/tls_sll_box.h" // Box TLS-SLL: C7-safe push/pop/splice
|
||||||
#include "box/tiny_next_ptr_box.h" // Box API: Next pointer read/write
|
#include "box/tiny_next_ptr_box.h" // Box API: Next pointer read/write
|
||||||
|
#include "box/tiny_front_config_box.h" // Phase 7-Step3: Compile-time config for dead code elimination
|
||||||
#ifdef HAKMEM_TINY_FRONT_GATE_BOX
|
#ifdef HAKMEM_TINY_FRONT_GATE_BOX
|
||||||
#include "box/front_gate_box.h"
|
#include "box/front_gate_box.h"
|
||||||
#endif
|
#endif
|
||||||
#include "hakmem_tiny_integrity.h" // PRIORITY 1-4: Corruption detection
|
#include "hakmem_tiny_integrity.h" // PRIORITY 1-4: Corruption detection
|
||||||
|
|
||||||
|
// Phase 7-Step3: Config wrapper functions (for normal mode, eliminated in PGO mode)
|
||||||
|
// These functions wrap global enable flags for dead code elimination in PGO builds
|
||||||
|
static inline int tiny_fastcache_enabled(void) {
|
||||||
|
extern int g_fastcache_enable;
|
||||||
|
return g_fastcache_enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int sfc_cascade_enabled(void) {
|
||||||
|
extern int g_sfc_enabled;
|
||||||
|
return g_sfc_enabled;
|
||||||
|
}
|
||||||
#ifdef HAKMEM_TINY_HEADER_CLASSIDX
|
#ifdef HAKMEM_TINY_HEADER_CLASSIDX
|
||||||
// Ring Cache and Unified Cache removed (A/B test: OFF is faster)
|
// Ring Cache and Unified Cache removed (A/B test: OFF is faster)
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user