Repository navigation
perf(daemon): hardlink-based byte-passing on cold compiles (closes #296) - #374
Merged
Merged
Conversation
Route the single-compile and link-ephemeral persist paths through the existing `persist_artifact_paths` (hardlink + copy-fallback) instead of `persist_artifact_payloads` (byte-write). This halves the Defender real-time scan wall-clock on cold compiles on Windows: the compiler already wrote `target/.../<output>` (scan #1); the daemon's previous byte-write of the same content to `~/.zccache/artifacts/<key>_<i>` was Defender scan #2. Hardlinking from the compiler's output path makes the cache file share the same inode — no additional bytes written, no extra scan. Cross-volume case is unchanged: `persist_artifact_file` falls back to `std::fs::copy`, identical to the prior byte-write semantics. Users on a separate dev drive can opt into `ZCCACHE_COLOCATE=1` (already wired in `core::config`) to place the cache on the project's volume so hardlinks succeed there too. The in-memory `CachedArtifact` still holds resident `Bytes` payloads (unchanged), so warm hits within the daemon's memory window stay on the inline-bytes fast path. Cold misses paid the eager `std::fs::read` of the output for the in-memory cache anyway; the only behavior change is that the daemon's *disk* write is now a hardlink syscall instead of a full content write. Sites changed: - `daemon/server/handle_compile.rs` single-compile miss persist (was `persist_artifact_payloads(...&payloads)`, now `persist_artifact_paths(...&[output_path])`). - `daemon/server/handle_link.rs` link-ephemeral miss persist (was `persist_artifact_payloads`, now `persist_artifact_paths` with `read_targets` source paths). `handle_compile_multi.rs` was already on the hardlink path (synchronous in the miss task, PR landed before #365). Its fallback `persist_jobs` queue is dead code today but kept for completeness. Also: add `zccache-cli` to `ci/release_checks.py::RUST_PUBLISH_ORDER` (stop hook was failing with "missing publishable crates: zccache-cli" because the Wave-6 collapse renamed `zccache-cli` to a pyo3 cdylib but the publish list wasn't updated). Verification: - `soldr cargo check --workspace --all-targets`: clean - `soldr cargo test --workspace --tests`: pass (env-specific `cli_installers` failures are pre-existing — missing `ctcb.exe`) - `uv run python ci/perf_local.py` (medium / cold-tar-untar-warm): PASS at 7.51x speedup, cold=1m02s warm=8.38s. Cold dropped slightly vs prior measurement; warm within run-to-run noise. The Defender payoff is Windows-host-specific and not measurable in the Linux Docker harness.
…-export CI on PR #374 surfaced three issues: - `crates/zccache/src/fingerprint/mod.rs:33` had a stale `#[cfg(feature = "python")] mod python;` referencing a file that was moved to the thin py-binding crate in wave 4. `-D unexpected-cfgs` rejected the dangling feature gate. Removed the line. - `crates/zccache/src/cli/mod.rs:15` re-exports `gc_daemon_spawn_logs` which is `#[deprecated]`. `-D warnings` rejected it. Added `#[allow(deprecated)]` on the re-export block (the deprecation note tells callers to use `gc_log_directory` instead, but the re-export keeps the public path stable). - `cargo fmt --all` reformatted 77 files. No semantic changes, just whitespace + import ordering.
Trailing-comment attributes must be on their own line per rustfmt rules. Wasn't caught by my prior `cargo fmt --all` because of the `mod python;` resolution error preempting the formatter.
CI on the second run surfaced three more `-D warnings`-promoted issues:
- Windows-only: ipc/mod.rs declares `extern \"system\" { fn CloseHandle... }`
in three places. windows-sys also defines CloseHandle with HANDLE/BOOL
newtypes; the underlying ABI matches but the signatures clash in
rustc's eyes (`clashing_extern_declarations` warn). Suppressed with
`#[allow(clashing_extern_declarations)]` on each block with a comment
explaining the rationale.
- Rustdoc: `symbols/mod.rs` had `[\`crate::marker\`]` and `[\`crate::cache\`]`
— broken since the monocrate collapse renamed paths. Fixed to
`[\`self::marker\`]` / `[\`self::cache\`]`.
- Rustdoc: `depgraph/snapshot/mod.rs` linked to `[\`tests\`]` (cfg(test)
module not visible to rustdoc). Demoted to plain backticks.
- Rustdoc: `cli/commands/mod.rs` links to `[\`args\`]` (private
sibling), `depgraph/snapshot/mod.rs` links to `[\`persistence\`]` (also
private). Both demoted to plain backticks — pub→priv links are an
error under `-D rustdoc::private-intra-doc-links`.
- Added README.md to `symbols/` and `depgraph/snapshot/` (readme_guard
hook required them after the Edits).
The bin compiles as a separate crate so [`Config::default`] doesn't resolve. Demote to plain backticks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #296.
Routes the single-compile and link-ephemeral persist paths through
persist_artifact_paths(hardlink + copy-fallback) instead ofpersist_artifact_payloads(byte-write). The compiler's output file → cache file becomes a hardlink (same inode, one Defender scan instead of two).Sites changed
`handle_compile_multi.rs` was already on the hardlink path (landed before #365).
Cross-volume
`persist_artifact_file` already falls back to `std::fs::copy` on `EXDEV` / `ERROR_NOT_SAME_DEVICE` — no behavior change there. Users on a separate dev drive can opt into `ZCCACHE_COLOCATE=1` (also already wired in `core::config`) to place the cache on the project's volume so hardlinks succeed.
In-memory cache
`CachedArtifact` still holds resident `Bytes` payloads so warm hits stay on the inline-bytes fast path. The only behavior change is the disk write becomes a link syscall instead of a full content write.
Verification (local)
Misc
Also adds `zccache-cli` back to `ci/release_checks.py::RUST_PUBLISH_ORDER` — the wave-6 collapse renamed it to a pyo3 cdylib but the publish-order check still required it to be listed.
🤖 Generated with Claude Code