35 lines
2.0 KiB
Markdown
35 lines
2.0 KiB
Markdown
|
|
# TINY CPU Hotpath Userland Analysis (Phase49)
|
|||
|
|
|
|||
|
|
- プロファイル: Mixed 16–1024B, ws=400, iters=1,000,000
|
|||
|
|
`HAKMEM_BENCH_MIN_SIZE=16 HAKMEM_BENCH_MAX_SIZE=1024 HAKMEM_TINY_HEAP_PROFILE=C7_SAFE HAKMEM_TINY_C7_HOT=1 HAKMEM_TINY_HOTHEAP_V2=0 HAKMEM_TINY_LARSON_FIX=1`
|
|||
|
|
- コマンド: `perf stat -e cycles:u,instructions:u,branch-misses:u ./bench_random_mixed_hakmem 1000000 400 1`
|
|||
|
|
`perf record -g -e cycles:u -o perf.data.mixed_u ./bench_random_mixed_hakmem 1000000 400 1`
|
|||
|
|
|
|||
|
|
## perf stat(userlandのみ)
|
|||
|
|
- Throughput: **41,000,086 ops/s**
|
|||
|
|
- cycles:u=126,239,279 / instructions:u=324,810,642 → IPC≈2.57
|
|||
|
|
- branch-misses:u=1,186,675
|
|||
|
|
- time=0.0438s(user 0.0295s / sys 0.0143s)
|
|||
|
|
|
|||
|
|
## perf record(cycles:u)上位シンボル(self%)
|
|||
|
|
- free: 24.3% — front入口/libc wrapper 部分
|
|||
|
|
- malloc: 18.0% — 同上
|
|||
|
|
- main: 15.3% — ベンチハーネス
|
|||
|
|
- tiny_heap_page_pop.lto_priv.0: 8.8% — TinyHeapBox ホット pop
|
|||
|
|
- hak_super_lookup.lto_priv.*: 7.9% — Superslab 判定(front→TinyHeapBox 境界前)
|
|||
|
|
- tiny_heap_page_becomes_empty.constprop.0: 5.9% — empty 遷移処理
|
|||
|
|
- __memset_avx2_unaligned_erms: 4.0% — ユーザランド初期化(first-touch)
|
|||
|
|
- tiny_region_id_write_header: 2.4% — header 書き込み
|
|||
|
|
- その他: __pthread_self / hak_free_at / tiny_heap_meta_flush_page などが1〜2%台
|
|||
|
|
|
|||
|
|
## 所感
|
|||
|
|
- ベンチ自身の malloc/free/main が大きいが、allocator 側では **tiny_heap_page_pop / hak_super_lookup / tiny_heap_page_becomes_empty** が目立つ。
|
|||
|
|
- userland側でも memset が残っており、first-touch 削減(ヘッダ書き込み削減や初期化遅延)余地がある。
|
|||
|
|
|
|||
|
|
## Phase50 で削るターゲット箱(提案)
|
|||
|
|
- **TinyHeapBox(C7/C6)の pop/empty + hak_super_lookup 前段**
|
|||
|
|
- super_lookup 依存の範囲チェックを軽量化 or キャッシュ化。
|
|||
|
|
- pop/empty 内の分岐を整理し、C7 SAFE の理想パス(current_page固定)に寄せる。
|
|||
|
|
- header write / memset を最小化する実験スイッチを検討。
|
|||
|
|
|