Skip to content

Commit 61e8d77

Browse files
committed
bench: bump fib to fib(40) for rayzor parity, skip on BC interp tiers
fib(40) makes ~331M recursive calls vs fib(30)'s 4.7M — apples-to- apples with rayzor's reference. New checksum 102_334_155. Added "fib" to the BC interp + interp-opt skip_kernels lists since the unscaled BC interp run is now ~10 minutes (vs ~5s for fib(30)) and the JIT tiers tell us what we need to know on the kernel. Page updated to show the new checksum in the overview.
1 parent 9e53f34 commit 61e8d77

3 files changed

Lines changed: 21 additions & 7 deletions

File tree

‎crates/zynml/examples/bench_fib.zynml‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
// Language Benchmarks Game lineage (used by wren_lift, rayzor,
44
// and the original `wren` repo too).
55
//
6-
// `fib(n)` makes `O(φⁿ)` calls — roughly 4.7 million calls for
7-
// `fib(30)`. That's the point: the bench measures function-call
6+
// `fib(n)` makes `O(φⁿ)` calls — roughly 331 million calls for
7+
// `fib(40)`. That's the point: the bench measures function-call
88
// dispatch and return overhead, not arithmetic. If the dispatch
99
// is fast, the number drops; if it's slow, the number goes up
1010
// and we know where to look.
1111
//
12-
// Returns `fib(30)` = 832040.
12+
// Matches rayzor's `fib(40)` reference so the cross-runtime
13+
// comparison stays apples-to-apples.
14+
//
15+
// Returns `fib(40)` = 102334155.
1316

1417
def fib(n: i64): i64 {
1518
if n < 2 {
@@ -19,5 +22,5 @@ def fib(n: i64): i64 {
1922
}
2023

2124
def main(): i64 {
22-
return fib(30)
25+
return fib(40)
2326
}

‎crates/zynml/examples/bench_runner.rs‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,15 @@ const TARGETS: &[Target] = &[
177177
// Newton-iter sqrt is similarly heavy. The interp/opt
178178
// tiers don't tell us anything the JIT tier doesn't tell
179179
// us better at full kernel scale, so skip for those two.
180-
skip_kernels: &["mandelbrot", "nbody", "nbody_ref"],
180+
skip_kernels: &["mandelbrot", "nbody", "nbody_ref", "fib"],
181181
},
182182
Target {
183183
key: "zyntax-interp-opt",
184184
label: "Zyntax · BC interp + opt",
185185
run_with_opts: true,
186186
install_jit: false,
187187
install_llvm: false,
188-
skip_kernels: &["mandelbrot", "nbody", "nbody_ref"],
188+
skip_kernels: &["mandelbrot", "nbody", "nbody_ref", "fib"],
189189
},
190190
Target {
191191
key: "zyntax-tiered",
@@ -302,6 +302,17 @@ fn jit_tier_config(install_llvm: bool) -> TieredConfig {
302302
hot_threshold: if install_llvm { 1 } else { u32::MAX as u64 },
303303
..ProfileConfig::default()
304304
};
305+
// Disable beadie's auto multi-tier promotion. The Cranelift compile
306+
// closure at interp_runtime.rs:769 deliberately ignores the tier
307+
// argument and always returns the Cranelift pointer (the LLVM tier
308+
// is wired through a separate hand-rolled side-channel that calls
309+
// `LLVMJitBackend::compile_function` directly). Leaving beadie's
310+
// tier 2 promotion broker enabled means it races the side-channel:
311+
// it submits a "tier 2" compile that re-fetches the Cranelift
312+
// pointer and bumps generation 1 → 2 before LLVM gets a chance,
313+
// and the side-channel's `generation() == 1` gate then misses.
314+
// Disable here so only the side-channel can flip past tier 1.
315+
cfg.enable_background_optimization = false;
305316
cfg
306317
}
307318

‎website/benchmark/index.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ <h1>What does <em>each tier</em> cost?</h1>
439439
875 × 500 / max_iter 1000 (reference checksum 112 798 515), n-body is
440440
the five-body solar system over 20 × 500 000 = 10 M advance steps
441441
returning <code style="font-family:'JetBrains Mono',monospace;font-size:0.92em;background:rgba(0,0,0,0.06);padding:0.05em 0.4em;border-radius:0.3em;">Std.int(energy · 1 000 000)</code>, fib is the naive recursive
442-
<code style="font-family:'JetBrains Mono',monospace;font-size:0.92em;background:rgba(0,0,0,0.06);padding:0.05em 0.4em;border-radius:0.3em;">fib(30) = 832 040</code>. The page exposes where the runtime needs
442+
<code style="font-family:'JetBrains Mono',monospace;font-size:0.92em;background:rgba(0,0,0,0.06);padding:0.05em 0.4em;border-radius:0.3em;">fib(40) = 102 334 155</code>. The page exposes where the runtime needs
443443
work; source lives at
444444
<a href="https://github.com/zyntax-project/zyntax/tree/main/crates/zynml/examples">crates/zynml/examples</a>.
445445
</p>

0 commit comments

Comments
 (0)