ClojureScript Compiler Perf

June 2, 2017

In his talk entitled The Next Five Years of ClojureScript, David Nolen spoke about the general maturity of ClojureScript. Given this, if you were to choose anything to focus on, one appropriate prioritization would be in the area of compiler performance. To me, this is just icing on the cake!

If you watch this bit, David predicts there is at least a 2× perf gain to be had. Well… I think we've now met this goal, and, to be honest, there is probably more that can be done to make things even faster.

Recently we landed a couple of compiler perf patches, one due to Andre Rauh. These improvements came about either by opening a profiler and seeing what was consuming all of the time, or by focusing on a known perf issue and digging until an explanation was found.

Note that these make the compiler itself faster (not the code emitted by the compiler). Having said that, scripting using self-hosted ClojureScript ends up blurring the distinction between compilation and execution, so compiler perf optimizations are extra beneficial for tools like Lumo and Planck.

If you are curious, you can measure the compiler speed if you include the :compiler-stats compiler option. Your mileage may vary, but here is what I'm seeing for :compiler-stats when running the ClojureScript compilation portion of the Planck build:

Before the patches (1.9.562):

Compile sources, elapsed time: 27757.805102 msecs

After the patches:

Compile sources, elapsed time: 13877.434417 msecs

As always, making optimizations to code could break things. My recommendation is to try ClojureScript master and try patches to see if things work for you without regression.

Tags: ClojureScript