58 lines
1.6 KiB
Markdown
58 lines
1.6 KiB
Markdown
|
|
# Phase 80-1: Inline Slots Switch Dispatch — Results
|
||
|
|
|
||
|
|
## Goal
|
||
|
|
|
||
|
|
Reduce per-op comparison/branch overhead in inline-slots routing for the hot classes by replacing the sequential `if (class_idx==X)` chain with a `switch (class_idx)` dispatch when enabled.
|
||
|
|
|
||
|
|
Scope:
|
||
|
|
- Alloc hot path: `core/box/tiny_front_hot_box.h`
|
||
|
|
- Free legacy fallback: `core/box/tiny_legacy_fallback_box.h`
|
||
|
|
|
||
|
|
## Change Summary
|
||
|
|
|
||
|
|
- New env gate box: `core/box/tiny_inline_slots_switch_dispatch_box.h`
|
||
|
|
- ENV: `HAKMEM_TINY_INLINE_SLOTS_SWITCHDISPATCH=0/1` (default 0)
|
||
|
|
- When enabled, uses switch dispatch for C4/C5/C6 (and excludes C2/C3 work, which is NO-GO).
|
||
|
|
- Reversible: set `HAKMEM_TINY_INLINE_SLOTS_SWITCHDISPATCH=0` to restore the original if-chain.
|
||
|
|
|
||
|
|
## A/B (Mixed SSOT, 10-run)
|
||
|
|
|
||
|
|
Workload:
|
||
|
|
- `ITERS=20000000`, `WS=400`, `RUNS=10`
|
||
|
|
- `scripts/run_mixed_10_cleanenv.sh`
|
||
|
|
|
||
|
|
Results:
|
||
|
|
|
||
|
|
Baseline (SWITCHDISPATCH=0, if-chain):
|
||
|
|
- Mean: `51.98M ops/s`
|
||
|
|
|
||
|
|
Treatment (SWITCHDISPATCH=1, switch):
|
||
|
|
- Mean: `52.84M ops/s`
|
||
|
|
|
||
|
|
Delta:
|
||
|
|
- `+1.65%` ✅ **GO** (threshold +1.0%)
|
||
|
|
|
||
|
|
## perf stat (single-run sanity)
|
||
|
|
|
||
|
|
Key deltas (treatment vs baseline):
|
||
|
|
- Cycles: `-1.6%`
|
||
|
|
- Instructions: `-1.5%`
|
||
|
|
- Branches: `-2.9%` ✅
|
||
|
|
- Cache-misses: `-6.7%`
|
||
|
|
- Throughput (single): `+3.7%`
|
||
|
|
|
||
|
|
Interpretation:
|
||
|
|
- Switch dispatch removes repeated failed comparisons for the hot inline-slot classes, reducing branches/instructions without causing cache-miss explosions.
|
||
|
|
|
||
|
|
## Promotion
|
||
|
|
|
||
|
|
Promoted to Mixed SSOT defaults:
|
||
|
|
- `core/bench_profile.h`: `HAKMEM_TINY_INLINE_SLOTS_SWITCHDISPATCH=1`
|
||
|
|
- `scripts/run_mixed_10_cleanenv.sh`: `HAKMEM_TINY_INLINE_SLOTS_SWITCHDISPATCH=1`
|
||
|
|
|
||
|
|
Rollback:
|
||
|
|
```sh
|
||
|
|
export HAKMEM_TINY_INLINE_SLOTS_SWITCHDISPATCH=0
|
||
|
|
```
|
||
|
|
|