Skip to content

perf(daemon): hardlink-based byte-passing on cold compiles (closes #296) - #374

Merged
zackees merged 5 commits into
mainfrom
perf/issue-296-hardlink-bytepassing
May 24, 2026
Merged

zackees merged 5 commits into
mainfrom
perf/issue-296-hardlink-bytepassing

Conversation

@zackees

@zackees zackees commented May 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #296.

Routes the single-compile and link-ephemeral persist paths through persist_artifact_paths (hardlink + copy-fallback) instead of persist_artifact_payloads (byte-write). The compiler's output file → cache file becomes a hardlink (same inode, one Defender scan instead of two).

Sites changed

  • `daemon/server/handle_compile.rs` single-compile cold-miss persist
  • `daemon/server/handle_link.rs` link-ephemeral cold-miss persist

`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)

  • `soldr cargo check --workspace --all-targets`: clean
  • `soldr cargo test --workspace --tests`: pass (env-only `cli_installers` failures, pre-existing — missing `ctcb.exe`)
  • `ci/perf_local.py` (medium / cold-tar-untar-warm): PASS at 7.51× speedup, cold 1m02s / warm 8.38s. The Defender win is Windows-host-specific and won't show up in the Linux Docker harness — the GHA perf cluster on Windows is the canonical measurement.

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

zackees added 5 commits May 23, 2026 19:02
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.
@zackees
zackees merged commit 218938c into main May 24, 2026
32 of 33 checks passed
@zackees
zackees deleted the perf/issue-296-hardlink-bytepassing branch May 24, 2026 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(daemon): hardlink-based byte-passing + ZCCACHE_COLOCATE for cross-volume cold compiles

1 participant