A drop-in Clojure-CLI replacement that gets you to the REPL fast.
Clojure is known for its slow start. This project utilizes Linux's Checkpoint/Restore functionality to cache JVM state to disk after Clojure finishes initialization. Subsequent Clojure launches are much faster by restoring from the cached state.
Read more about the design process: part 1 part 2.
Clojure-CLI-CRaC requires bash
and rlwrap
. It can be used alongside the offical Clojure CLI.
- Clone this repo
git clone https://github.com/YizhePKU/Clojure-CLI-CRaC.git
- Download the latest build of JDK with CRaC. Unpack with
sudo
(sudo
is necessary because it contains a setuid executable for triggering Checkpoint/Restore)
wget https://github.com/CRaC/openjdk-builds/releases/download/17-crac%2B5/openjdk-17-crac+5_linux-x64.tar.gz
sudo tar xf openjdk-17-crac+5_linux-x64.tar.gz
- Move the unpacked directory into this repo. Rename it to
openjdk-17-crac
sudo mv openjdk-17-crac+5_linux-x64 Clojure-CLI-CRaC/openjdk-17-crac
- (Optional) add the
bin/
directory to your PATH
Clojure-CLI-CRaC is a drop-in Clojure CLI replacement. Run clojure
and clj
as you normally would.
- JVM options can only be set on the first launch (otherwise they have no effect)
- Will automatically invalidate the checkpoint when
deps.edn
changes (e.g. new dependencies)
- Currently Linux-x86_64 only
- Will print a bunch of nonsense when creating a checkpoint
- There's currently an upstream bug that causes whitespace in command line arguments to be misinterpreted