Direct Linking in Clojure

Does static go faster?

Daniel gave a talk about the performance impact of vars in 2014: Daniel Solano Gomez - How Clojure Works: Understanding the Clojure Runtime. Clojure 1.8+ has the :direct-linking feature (added in 2016). See compiler-options.

I couldn’t find a quantification of the performance impact turning on :direct-linking has. It strikes me as odd that this wouldn’t be a much more commonly discussed and documented deployment option. Does anyone have any benchmarks or anecdotes about this?

GraalVM compile times claims a very significant performance boost.

I’ve tried to create a very simple benchmark project to observe the performance effect, but no effect is observed. Am I doing it wrong?

Usage

For convenience, a Makefile is provided that will time the examples

$ make
time clj -M:hello-dynamic
Hello world

        0.81 real         1.46 user         0.16 sys
time clj -M:hello-static
Hello world

        0.78 real         1.43 user         0.16 sys
time clj -M:hello-compile
direct.hello

        0.80 real         1.45 user         0.16 sys
time java -cp `clj -Spath` direct.hello

Hello world

real	0m0.797s
user	0m1.439s
sys	0m0.162s
time clj -M:primes-dynamic
Found  17984  primes

        5.53 real         6.31 user         0.36 sys
time clj -M:primes-static
Found  17984  primes

        5.62 real         6.22 user         0.37 sys
time clj -M:primes-compile
direct.primes

        0.85 real         1.40 user         0.17 sys
time java -cp `clj -Spath` direct.primes

Found  17984  primes

real	0m5.922s
user	0m6.771s
sys	0m0.416s

For my experiment, :direct-linking makes no improvement at all.

References