Improving JVM Clojure Startup Time with Checkpoint/Restore
The article discusses the issue of long startup time in JVM Clojure and introduces a promising solution called Checkpoint/Restore. It explains that the initialization of the clojure.core namespace, which contains over 600 functions and variables, is the main cause of the slow start. To address this, the author suggests using CRIU (Checkpoint/Restore In Userspace), a Linux tool that can freeze a running program and save its state to disk. The saved state can then be restored later, resulting in faster startup times. The author mentions CRaC (Coordinated Restore at Checkpoint), an OpenJDK side-project that adds support for Checkpoint/Restore from the JVM. By initializing Clojure once and requesting a checkpoint, developers can achieve faster startup times for their Clojure REPL. The article provides a step-by-step guide for implementing this solution. This approach combines the power of JVM Clojure with the speed of Babashka, a custom interpreter for Clojure code. This is great news for developers who need fast startup times without sacrificing the functionality of third-party libraries.