I am not sure if this will happen to anyone else. But I thought I would share the answer to my struggles in the past couple of days to speed up Leiningen startup times.

I have been running benchmarks using lein-jmh , which launches a new JVM process for each different benchmark. For some reason, it would take minutes to even begin benchmarking on the server I was using. I tried a bunch of things (installing a new Java version, a new Lein version, trampoline, profiling), but I couldn’t figure it out! It would sometimes be fast, but then get mysteriously slower again.

Five minutes ago, I re-enabled class loading debugging in my project.clj and looked at the output again:

:jvm-opts ^:replace ["-verbose:class"]

…and found it was spending ~1 minute loading the init functions in a couple of namespaces. Each had something like this:

(def ^:dynamic *thread-local-random-generator* (random/make-mersennetwister-rng))

Aha! It must need some random data to create this RNG. I checked my entropy levels and they were really low! So I sudo apt-get install haveged and my entropy went magically up and now what was taking two minutes is taking 10 seconds!

Hopefully no one else will spend hours and hours with something so silly…