You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Path A.3: bench tree-walk vs VM vs JIT-via-dispatch vs JIT-direct
Closes the open question from Session E: how much of the 272x
JIT speedup is "vs tree-walk" vs "vs the bytecode VM"?
Same workload (bench_loop(N) = sum factorial(12) over N iters) run
through four modes:
Mode Per-iter ns vs tree-walk
Tree-walk 14,462 1.0x
Bytecode VM 6,929 2.1x
JIT-via-dispatch 58.2 249x
JIT-direct 53.1 272x
Two findings worth surfacing:
1. The bytecode VM is 2.1x faster than tree-walk, not 10x. Most of
the JIT's measured speedup is JIT itself, not VM-vs-tree-walk.
The honest comparison: JIT is 119x faster than VM on this
workload, on top of VM being 2x faster than tree-walk. The known
VM shim costs (vm_call_builtin synthetic-arg path) cap how much
the bytecode VM can win without further optimization.
2. JIT-via-dispatch is essentially as fast as JIT-direct (58.2 vs
53.1 ns, 9% overhead). The OMC tree-walk loop wrapping a JIT'd
fn body adds negligible cost — Session E's 272x microbench number
IS what real OMC programs experience when the hot fn is JIT'd.
The implication: enabling OMC_HBIT_JIT=1 on a program with a JIT-
eligible hot fn delivers close to the full 250x on those calls,
not just the 5% headroom over JIT-direct that microbenches measure.
docs/jit_benchmark.md updated with the Path A.3 section.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|`sum_to(100)` — 100-iter while loop with locals | 53,202 ns | 267 ns |**200×**|
54
54
55
+
## Path A.3: same workload, four execution modes
56
+
57
+
Closes the comparison gap from Session E (which only timed tree-walk vs JIT-direct). The same `bench_loop(N) = sum factorial(12) over N iters` workload runs through four execution strategies; per-iteration time reported as total/N.
| JIT-via-dispatch | 58.2 | 249× | Tree-walk runs the loop; factorial routed through JIT |
64
+
| JIT-direct (Rust loop) | 53.1 | 272× | Bypasses OMC entirely on the hot path |
65
+
66
+
**Two findings:**
67
+
68
+
1.**The bytecode VM is 2.1× faster than tree-walk, not 10×.** This matches the prior known costs of `vm_call_builtin`'s synthetic-arg shim and other VM-side dispatch overhead. The JIT's real comparison advantage is **119× faster than the bytecode VM**, on top of VM being 2× faster than tree-walk.
69
+
2.**JIT-via-dispatch (58.2 ns) is essentially as fast as JIT-direct (53.1 ns)** — only ~9% overhead from routing through the Interpreter's dispatch hook. This means the 272× number from the Session E microbench is what real OMC programs experience; the OMC tree-walk loop wrapping a JIT'd fn body is negligible.
70
+
71
+
The implication: enabling `OMC_HBIT_JIT=1` on a real OMC program where the hot fn is JIT-eligible (pure-int, no strings/arrays/builtins) will give close to the full ~250× speedup on that fn's invocations.
After Sessions F (phi_shadow → divergent β) and G (harmony() intrinsic + extern call), an OMC fn can use harmony as a runtime signal to choose between cheap and expensive code paths. The bench source:
0 commit comments