The recent releases of Java 8u201/8u202 and 11.0.2 include a fix for a 0-day vulnerability that could occur while running a class static initializer. The fix included in these releases prevents JVM optimization during the static initializer (before the class is initialized). Doing significant work in the static initializer can see dramatic reduction in performance from the previous versions 8u192 / 11.0.1.
Clojure supports a well-known file user.clj that is loaded during runtime initialization (in the clojure.lang.RT class). This is sometimes used to load tools during development. Currently user.clj is loaded in the scope of RT's static inititializer, so any Clojure code run in user.clj is significantly slower.
One common pattern popularized by Stuart Sierra is the "reloaded" pattern which will load and initialize the entire server from the user.clj. Users of this pattern are likely to see dramatic startup time performance issues with these Java releases.
- http://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8219233 - a bug filed for this issue
This repo includes a simple case reproducing the issue. foo.clj measures
the time to do some meaningless busy work. You can run this as a
$ clj foo.clj
Or you can run it by loading it in user.clj by adding the
$ clj -A:user
The timings were collected on a 2018 Macbook Pro, but this issue is not OS or architecture dependent.
|1.8.0_192||37 ms||40 ms|
|1.8.0_201||32 ms||577 ms|
|11||39 ms||58 ms|
|11.0.2||40 ms||864 ms|