Broaden the benchmark suite; add jolt-vs-JVM scorecard (#140)
The ray tracer is compute-bound and the three existing benches only cover alloc / megamorphic-dispatch / collections. Add three axes the epic needs to judge itself holistically: - mono-dispatch: monomorphic protocol dispatch. Its jolt/JVM ratio (~110x) is *worse* than megamorphic (~76x) — the JVM inline-caches a runtime-monomorphic call site to near-free while jolt does a full registry dispatch (devirt only fires on statically-proven receivers). Points at the call-site inline cache. - mandelbrot: pure float compute, no alloc/dispatch. The floor at ~15x — native arith already gets close to the JVM. - fib: recursion, call + integer-arith overhead. run.sh gains JVM=1, which runs each bench on JVM Clojure too and prints the jolt/JVM ratio. collections sized up now that the map is a HAMT (jolt-684u). README documents the axes and the current scorecard. Co-authored-by: Yogthos <yogthos@gmail.com>
This commit is contained in:
parent
f0293fb4ee
commit
7d0b1d5695
5 changed files with 166 additions and 15 deletions
29
bench/fib.clj
Normal file
29
bench/fib.clj
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
;; fib — naive recursive Fibonacci: pure function-call + integer-arithmetic
|
||||
;; throughput, with no allocation, dispatch, or collections. Isolates call
|
||||
;; overhead and native integer arith (jolt-3pl), and is the natural target for
|
||||
;; single-call-site / small-fn inlining (jolt-826) and self-call direct-linking.
|
||||
;;
|
||||
;; Portable Clojure (jolt + JVM Clojure).
|
||||
;; jolt -m fib 32 (JOLT_DIRECT_LINK=1 JOLT_WHOLE_PROGRAM=1)
|
||||
(ns fib)
|
||||
|
||||
(defn fib [n]
|
||||
(if (< n 2) n (+ (fib (- n 1)) (fib (- n 2)))))
|
||||
|
||||
(defn run [n] (fib n))
|
||||
|
||||
(defn -main [& args]
|
||||
(let [n (if (seq args) (Integer/parseInt (first args)) 32)]
|
||||
(dotimes [_ 2] (run (- n 6))) ; warmup
|
||||
(let [runs 3
|
||||
times (mapv (fn [_]
|
||||
(let [t0 (System/nanoTime)
|
||||
r (run n)
|
||||
ms (/ (- (System/nanoTime) t0) 1000000.0)]
|
||||
[ms r]))
|
||||
(range runs))
|
||||
mss (mapv first times)
|
||||
mean (/ (reduce + mss) runs)]
|
||||
(println "fib n" n "result" (second (first times)))
|
||||
(println "runs:" (mapv (fn [t] (/ (Math/round (* t 10.0)) 10.0)) mss))
|
||||
(println "mean:" (/ (Math/round (* mean 10.0)) 10.0) "ms"))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue