Phase 5 E4-2: Malloc Wrapper ENV Snapshot (+21.83% GO, ADOPTED)
Target: Consolidate malloc wrapper TLS reads + eliminate function calls
- malloc (16.13%) + tiny_alloc_gate_fast (19.50%) = 35.63% combined
- Strategy: E4-1 success pattern + function call elimination
Implementation:
- ENV gate: HAKMEM_MALLOC_WRAPPER_ENV_SNAPSHOT=0/1 (default 0)
- core/box/malloc_wrapper_env_snapshot_box.{h,c}: New box
- Consolidates multiple TLS reads → 1 TLS read
- Pre-caches tiny_max_size() == 256 (eliminates function call)
- Lazy init with probe window (bench_profile putenv sync)
- core/box/hak_wrappers.inc.h: Integration in malloc() wrapper
- Makefile: Add malloc_wrapper_env_snapshot_box.o to all targets
A/B Test Results (Mixed, 10-run, 20M iters):
- Baseline (SNAPSHOT=0): 35.74M ops/s (mean), 35.75M ops/s (median)
- Optimized (SNAPSHOT=1): 43.54M ops/s (mean), 43.92M ops/s (median)
- Improvement: +21.83% mean, +22.86% median (+7.80M ops/s)
Decision: GO (+21.83% >> +1.0% threshold, 21.8x over)
- Why 6.2x better than E4-1 (+3.51%)?
- Higher malloc call frequency (allocation-heavy workload)
- Function call elimination (tiny_max_size pre-cached)
- Larger target: 35.63% vs free's 25.26%
- Health check: PASS (all profiles)
- Action: PROMOTED to MIXED_TINYV3_C7_SAFE preset
Phase 5 Cumulative (estimated):
- E1 (ENV Snapshot): +3.92%
- E4-1 (Free Wrapper Snapshot): +3.51%
- E4-2 (Malloc Wrapper Snapshot): +21.83%
- Estimated combined: ~+30% (needs validation)
Next Steps:
- Combined A/B test (E4-1 + E4-2 simultaneously)
- Measure actual cumulative effect
- Profile new baseline for next optimization targets
Deliverables:
- docs/analysis/PHASE5_E4_2_MALLOC_WRAPPER_ENV_SNAPSHOT_1_DESIGN.md
- docs/analysis/PHASE5_E4_2_MALLOC_WRAPPER_ENV_SNAPSHOT_1_AB_TEST_RESULTS.md
- docs/analysis/PHASE5_E4_2_MALLOC_WRAPPER_ENV_SNAPSHOT_NEXT_INSTRUCTIONS.md
- docs/analysis/PHASE5_E4_COMBINED_AB_TEST_NEXT_INSTRUCTIONS.md (next)
- docs/analysis/ENV_PROFILE_PRESETS.md (E4-2 added)
- CURRENT_TASK.md (E4-2 complete)
- core/bench_profile.h (E4-2 promoted to default)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -0,0 +1,48 @@
|
||||
# Phase 5 E4 (E4-1 + E4-2): Combined A/B(次の指示書)
|
||||
|
||||
## 目的
|
||||
|
||||
E4-1(free wrapper snapshot)と E4-2(malloc wrapper snapshot)の “累積効果” を確認し、次の perf ターゲットを確定する。
|
||||
|
||||
---
|
||||
|
||||
## A/B(Mixed 10-run)
|
||||
|
||||
```sh
|
||||
# Baseline: both OFF
|
||||
HAKMEM_PROFILE=MIXED_TINYV3_C7_SAFE \
|
||||
HAKMEM_FREE_WRAPPER_ENV_SNAPSHOT=0 \
|
||||
HAKMEM_MALLOC_WRAPPER_ENV_SNAPSHOT=0 \
|
||||
./bench_random_mixed_hakmem 20000000 400 1
|
||||
|
||||
# Optimized: both ON
|
||||
HAKMEM_PROFILE=MIXED_TINYV3_C7_SAFE \
|
||||
HAKMEM_FREE_WRAPPER_ENV_SNAPSHOT=1 \
|
||||
HAKMEM_MALLOC_WRAPPER_ENV_SNAPSHOT=1 \
|
||||
./bench_random_mixed_hakmem 20000000 400 1
|
||||
```
|
||||
|
||||
判定:
|
||||
- GO: mean **+1.0% 以上**
|
||||
- ±1%: NEUTRAL(freeze)
|
||||
- -1% 以下: NO-GO(freeze)
|
||||
|
||||
---
|
||||
|
||||
## 健康診断
|
||||
|
||||
```sh
|
||||
scripts/verify_health_profiles.sh
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 次のアクション
|
||||
|
||||
```sh
|
||||
HAKMEM_PROFILE=MIXED_TINYV3_C7_SAFE perf record -F 99 -- \
|
||||
./bench_random_mixed_hakmem 20000000 400 1
|
||||
perf report --stdio --no-children
|
||||
```
|
||||
|
||||
“self% ≥ 5%” の箱から次の芯を選ぶ。
|
||||
Reference in New Issue
Block a user