Repository navigation
perf(ci): split er-api's dependency layer out with cargo-chef - #423
Conversation
ff26b0d to
a2a68af
Compare
…entically The prediction recorded in the previous commit resolved to structural, and PRs are red again. #423's run, unchanged Cargo.toml, restored the v2 entry and panicked the same way: Cache hit for: v2-rust-rust-Linux-x64-8556beb2-11e7c23f Restored from cache key "v2-rust-..." full match: true. unpacking bundled DuckDB sources: Os { code: 39, DirectoryNotEmpty } `full match: true` is the point. The rust-cache KEY matched exactly; what did not match is cargo's own fingerprint for the build script, which that key does not model — two different notions of "valid cache", only one of them checked. So a prefix bump buys exactly one cold green run per bump (8578f99 was that run) and the next restore breaks again. rust-cache therefore comes out of all seven sccache-backed compile jobs. sccache is content-addressed per compilation unit and never touches `target/`, so it cannot fail this way, and it was already doing the work: two runs with `No cache found.` at a 99% hit rate finished in 8m03/8m45 while this entry held ~1.3 GB. Measured on this branch before the rebase: 8-13m per job, in line with the sharded baseline. `coverage` keeps its entry — it opts out of sccache (llvm-cov owns RUSTFLAGS), so there the trade really is 1.8 GiB against a timeout. This also retires the single-writer rule: nothing in the Rust gate writes the Actions cache now. Co-Authored-By: Claude Fable 5 <[email protected]>
|
The |
|
Full local validation finished: exit 0, including the cook, the workspace build and the extension bake. It also measures the split precisely (arm64 laptop, so treat the absolute numbers as indicative and the ratio as the result):
The workspace is 3.8% of the compile work. Everything else is the dependency graph that today's The flip side, stated honestly: a merge that changes |
… red again (#424) * docs(ci): record the rust-cache poisoning incident and what settles it #422 fixed the red main by bumping prefix-key to v2. This writes down the trail — including that the poisoning commit PASSES and the next unrelated PR wears it, which is what made it look like those PRs' fault — and states the one open question as an observation rather than an argument. The mechanism needs only a restored populated out/ plus a fingerprint mismatch, and this repo's jobs legitimately differ in fingerprint (lint is the sole writer; test, the lake shards and the e2e slices each select different packages and features). So either the mismatch only arises at a dependency bump (v2 holds) or lint's tree can never satisfy the others (v2 breaks on first restore). The discriminating observable is the next main run with an unchanged Cargo.toml; the remedy if it is red is recorded with it. Co-Authored-By: Claude Fable 5 <[email protected]> * fix(ci): remove rust-cache — v2 was restored full-match and failed identically The prediction recorded in the previous commit resolved to structural, and PRs are red again. #423's run, unchanged Cargo.toml, restored the v2 entry and panicked the same way: Cache hit for: v2-rust-rust-Linux-x64-8556beb2-11e7c23f Restored from cache key "v2-rust-..." full match: true. unpacking bundled DuckDB sources: Os { code: 39, DirectoryNotEmpty } `full match: true` is the point. The rust-cache KEY matched exactly; what did not match is cargo's own fingerprint for the build script, which that key does not model — two different notions of "valid cache", only one of them checked. So a prefix bump buys exactly one cold green run per bump (8578f99 was that run) and the next restore breaks again. rust-cache therefore comes out of all seven sccache-backed compile jobs. sccache is content-addressed per compilation unit and never touches `target/`, so it cannot fail this way, and it was already doing the work: two runs with `No cache found.` at a 99% hit rate finished in 8m03/8m45 while this entry held ~1.3 GB. Measured on this branch before the rebase: 8-13m per job, in line with the sharded baseline. `coverage` keeps its entry — it opts out of sccache (llvm-cov owns RUSTFLAGS), so there the trade really is 1.8 GiB against a timeout. This also retires the single-writer rule: nothing in the Rust gate writes the Actions cache now. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: bmoore813 <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
`COPY . .` then one `cargo build --release` meant ANY change under rust/ — a one-line handler edit — invalidated the build layer and recompiled all 408 crates, bundled DuckDB's C++ included. Measured twice today: 58m9s on the main build (run 41524220825) and 51m cold in the new PR verify job. Every rust-touching merge paid it, with deploy-dev waiting behind. cargo-chef splits it: `prepare` reduces the workspace to a recipe (manifests + lockfile, no sources), `cook` builds the dependency graph against stubbed workspace crates, and sources arrive in a later layer. A source-only change now reuses the cooked dependencies — the ECR registry cache carries that layer between runs — and recompiles only this workspace's 33 crates. The recipe changes when Cargo.toml or Cargo.lock does, which is exactly when the dependency build must genuinely re-run. Two details that would have silently undone it: `.cargo/config.toml` is copied BEFORE the cook, because its CXXFLAGS are part of libduckdb-sys's fingerprint and cooking without it builds DuckDB twice; and `--bin er-server` is passed to cook as well as build, because cargo resolves features per selected target and a whole-workspace cook would unify a different set. No build.rs exists anywhere in the workspace, which is the usual thing that breaks a chef stub phase. Validated locally through `prepare` (a 191KB recipe naming er-server and libduckdb-sys) and in CI by the verify job this PR runs. Co-Authored-By: Claude Fable 5 <[email protected]>
a2a68af to
d1b390d
Compare
The measurement
rust/DockerfiledidCOPY . .then onecargo build --release, so any change underrust/recompiled all 408 crates including bundled DuckDB's C++. Measured twice today: 58m9s on the main build (run 41524220825) and 51m cold in the new verify job — paid on every rust-touching merge, withdeploy-devqueued behind it.The change
cargo-chef (pinned 0.1.78) splits the build in two:
preparereduces the workspace to a recipe (manifests + lockfile, no sources),cookbuilds the dependency graph against stubbed workspace crates, and sources arrive in a later layer. A source-only change then reuses the cooked dependency layer — which the ECR registry cache (#405/#407) carries between runs — and recompiles only the 33 workspace crates. The recipe changes whenCargo.toml/Cargo.lockdoes, which is exactly when the dependency build genuinely must re-run.Two details that would have silently undone the whole thing:
.cargo/config.tomlis copied before the cook. ItsCXXFLAGS(the DuckDB release-version stamp) are part oflibduckdb-sys's fingerprint — cooking without it builds DuckDB once in the cook and again after the sources arrive, i.e. the most expensive crate in the graph compiled twice for no gain.--bin er-serveris passed tocookas well asbuild. Cargo resolves features per selected target, so a whole-workspace cook would unify a different feature set and every crate whose features differed would recompile.Why this is safe to land
Nothing in the workspace has a
build.rs(checked) — that is the usual thing that breaks chef's stub phase. The restructure was validated locally throughprepare(a 191KB recipe naminger-serverandlibduckdb-sys), and this PR is validated by theverifyjob added in #417 — the first Dockerfile change that gets a pre-merge build at all. Expectimage builds (er-api, no push)to run cold here (~50m); the saving shows on the second build with a warm cache, which the first main build after merge will demonstrate.🤖 Generated with Claude Code