The jank Clojure dialect compiler now has a custom SSA-based intermediate representation (IR) operating at Clojure's semantic level, enabling high-level optimizations that LLVM IR cannot perform. The post walks through a series of optimizations applied to a recursive fibonacci benchmark: arithmetic inlining (5522ms → 2309ms), eliminating redundant IR instructions (→ 2247ms), fixing nil access overhead (→ 1400ms), implementing pointer tagging for 63-bit integers to eliminate heap allocations (→ 282ms), and forcing inlining of arithmetic functions via C++ attributes (→ 114ms). The final result is jank running nearly 2x faster than Clojure JVM for this benchmark, down from being 27x slower.

25m read timeFrom jank-lang.org
Post cover image
Table of contents
What is an intermediate representation (IR)?Custom IR rationaleCustom IR detailsOptimizing the IRInterludeOptimizing recursive fibonacciWhat's nextA note about the JVM versus nativeWould you like to join in?

Sort: