| name | compiler-perf-profiling |
| description | vibe compiler の性能改善手順 — node --cpu-prof での実コンパイルのプロファイル取得、phase bench (__bench_ export) の実行、ホットスポットの読み方、修正→fixpoint→回帰の検証ループ。コンパイルが遅い・CI が遅い・bench の退行を調べるときに使う。 |
compiler perf profiling — 計測してから直す
vibe compiler (selfhost, linear/RC lane) の性能改善は「synthetic bench で当たり
をつける」より「実コンパイルを node --cpu-prof でプロファイルする」方が
圧倒的に速く核心に届く。#799 でこの手順により重量級コンパイルを 39s→4s
(約10倍) にした実績がある。
0. ワンコマンド: scripts/profile_compile.sh
§1 の cpu-prof + self-time 集計と §3 のメモリ統計 (heap 高水位 / linear
memory / RSS) を 1 コマンドに束ねたもの。まずこれを叩き、深掘りが必要に
なったら §1 以降の手作業に降りる。
scripts/profile_compile.sh /tmp/gen/stage2.wasm
scripts/profile_compile.sh /tmp/gen/stage2.wasm foo.vibe 30
1. まず実コンパイルをプロファイルする (最重要)
S2=<stage2.wasm>
VIBE_PREOPEN_DIR="$PWD" VIBE_FS_COMPILE=1 VIBE_IMPORT_ABI=raw \
node --cpu-prof --cpu-prof-dir=/tmp --cpu-prof-name=compile.cpuprofile \
scripts/wasm_vibe_host_runner.js --invoke cli_main "$S2" \
lib/@vibe/compiler/tests/codegen_lexer_test.vibe /tmp/out.wasm __no_entry__
対象は「compiler closure を丸ごと compile する重いテスト」(codegen_test /
cli_test / selfhost_s5 など) が良い。self 時間の集計:
import json, collections
p = json.load(open("/tmp/compile.cpuprofile"))
nodes = {n["id"]: n for n in p["nodes"]}
c = collections.Counter()
for sid, dt (p[], p[]):
c[nodes[sid][][] ] += dt
total = (c.values())
fn, us c.most_common():
()