Daemon overview
What the background daemon owns and what still works without it
The daemon keeps compiler cache pipelines, network connections and maintenance state warm across invocations. The local engine can still use the cache when compiler delegation is unavailable.
V2 starts or uses this daemon for eligible local builds as well as remote-backed
builds. It is a per-user cache process, separate from the optional remote planner
service. Keep using kache; the matching kache-engine companion runs its CLI
and daemon entry points.
Responsibilities
- Run concurrent cache pipelines for delegated compiler invocations.
- Download an exact entry after a local miss.
- Store completed C/C++ compiles handed over by wrappers.
- Upload newly stored entries in the background.
- Replay durable upload intents after a restart.
- Prefetch likely entries at the start of a build session.
- Prepare cold MSVC runtime hashes while native compiles run without caching.
- Refresh the remote key index used by fallback planning.
- Run garbage collection at startup and every six hours, including
[cache.volumes]shards. When the store is over its size limit, also sweep after an upload or when a wrapper reports it. - Flush entries that were stored without an fsync, every two seconds.
- At the start of a build, copy large executables next to the paths their restore will write, so the restore only renames the copy into place.
- When the machine is quiet, heal the blob index and compact
index.db. - When the machine is quiet, at most once an hour, remove tracked target directories whose workspace was deleted, and build units no build has used for 30 days. See Target directory cleanup.
- While the machine is idle, replace target files that are full copies of stored blobs with clones of those blobs.
- Copy another checkout's registry and git dependency units into a new target directory before Cargo checks it. See New checkouts.
- Fetch input-prediction rows from the remote, and publish them to a writable one.
- When a build session that used a writable remote has been idle for five minutes, publish its build manifest.
- Track running compiles for
kache monitor. - On macOS, exclude the cache directory from Spotlight and Time Machine.
- Exit when its config file changes, so the next start loads the new settings.
For delegated compiles, the daemon's pipeline already owns publication. A local
C/C++ engine can also hand its private output snapshots to the daemon when
cache.daemon_publish is enabled (the default). If the daemon cannot accept that
handoff within 25 ms, the engine publishes locally. Local execution using a
[cache.volumes] shard publishes from the engine.
Report JSON marks daemon-owned publication with store_handed_off. Queued
publication records its background time in daemon_store_ms, separately from
store_ms. A delegated pipeline that stores directly has no queued background
time. A daemon crash can lose queued cache entries; the compiler outputs remain
available to the build.
Set cache.prefetch_enabled = false or KACHE_PREFETCH_ENABLED=0 to disable speculative prefetch while retaining exact remote checks and uploads.
Adaptive cancellation counts every entry in the selected build manifest as a candidate, including cheap crates skipped for download. These candidates stay with the build session when its planner changes. Demands outside both the manifest and the selected plan can still cancel unhelpful prefetch.
The daemon lists the remote's keys only when cache.remote_key_listing is on. It is on by default for a filesystem remote and off for S3, GCS and OCI; on S3 it needs s3:ListBucket. Nothing is listed while cache.prefetch_enabled is off. The planner uses this key index for crates that no build manifest, shard or local history covers, and the daemon refreshes it every cache.remote_key_cache_refresh_secs (60 by default; 0 lists once). If S3 refuses the listing for lack of s3:ListBucket, the daemon stops listing and logs one warning.
When it is required
Local-only caching can fall back to the local engine when delegation is
unavailable; this is not the normal way to disable the daemon. Compiler-driven remote reads, writes,
and prefetch need the daemon. kache sync can transfer entries directly without
it. If delegation is unavailable before Commit, the engine continues with the
local store. After Commit, a lost daemon connection fails the invocation; see
Architecture.
Endpoint placement
The runtime directory defaults to the cache directory. On Unix the default socket is <runtime_dir>/daemon.sock; Windows derives a named-pipe name from that path. Move the runtime directory with [cache] runtime_dir or KACHE_RUNTIME_DIR, or only the endpoint with an absolute KACHE_SOCKET_PATH. KACHE_SOCKET_PATH has no config-file key, and a relative or unusable value is ignored with a warning.
The daemon also binds a lifecycle control endpoint next to the socket: the socket path with its extension replaced by .ctl. With the default daemon.sock it is one byte shorter than the socket. A custom KACHE_SOCKET_PATH without an extension gets a longer one.
Use a short, user-owned runtime directory. Unix socket paths are limited to 103 bytes on macOS and 107 on Linux. kache daemon start checks both endpoint paths against that limit and refuses to start a daemon when either is too long. Shared temporary directories also allow another local user to interfere with adjacent lock and state files.
Every client and daemon process must resolve the same runtime and socket settings. Installed services do not inherit later shell exports; put persistent values in the config or service definition.
Basic commands
kache daemon start
kache daemon status
kache daemon log
kache daemon stop
Bare kache daemon is an alias for kache daemon status. The status lists the CLI and daemon versions, whether the login service is installed, and where the socket, logs and startup errors are.
See Lifecycle for service installation and restart behavior.