Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The Compiler Daemon

Status: 🟢 On by default, on every Kotlin version Kargo supports.

The Kotlin compiler is a large Java program, and most of what a short build costs is starting one: a fresh JVM, a cold compiler, no warm JIT. The daemon is one compiler process that stays alive between builds, so the second build and every build after it start warm.

On a 400-file project, one file edited:

wall clock
No daemon11.7s
Daemon, plus incremental compilation3.2s

Both backends use it. On the kotlinc path it makes a full recompile roughly twice as fast; with the build-tools backend it compounds with recompiling only what changed.

What Kargo keeps

One daemon per compiler version, JDK and set of JVM arguments — a daemon holds one loaded compiler, and reusing it for a build that wants another would hand that build the wrong one. Each lives under ~/.kargo/daemon/, and shuts itself down after fifteen minutes with nothing to do.

kargo cache stats          # whether one is running, and what it holds
kargo cache stop-daemon    # stop it now

A daemon that cannot start is never a failed build: Kargo compiles in a fresh JVM instead and says so under -v.

Turning it off

A one-shot build has nothing to reuse a daemon for, and leaving a JVM behind on a CI runner is a cost with no return. Any of these is enough:

# ~/.kargo/config.toml
[build]
daemon = false
kargo build --no-daemon
KARGO_NO_DAEMON=1 kargo build

When it will not help

  • The first build after a toolchain change. A new Kotlin or JDK is a new daemon, and the first build pays for starting it.
  • A build that compiles nothing. The fingerprint already answers those without a compiler at all.
  • kargo clean followed by a build. The daemon is still warm, but there is a whole project to compile through it.