Repository navigation
fix(graph): lock cache-miss actions by output path - #429
Merged
Merged
Conversation
Concurrent test batches can compute different digests for the same action when an upstream build is not reproducible or the host analysis differs, so the digest lock let two rustc runs share one out-dir and delete each other's object files. Lock each declared output path instead, falling back to the digest for actions without outputs. Amp-Thread-ID: https://ampcode.com/threads/T-01a1c142-88f4-71a1-9ae1-20b34c4a6881 Co-authored-by: Marek Fort <marek@tuist.dev>
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
The
tests (macos-latest)job intermittently fails with rustc archive errors such asfailed to build archive at .once/out/rustls-0.23.40/librustls-RUSTLS_0_23_40.rlib: failed to map object file: memory map must have a non-zero length(run 42652108237, on a tree identical to a passing commit).The test schedule runs several
once testprocesses in one workspace. Cache-miss actions were serialized by a lock keyed on the action digest, but a Rust crate's out-dir is keyed by its label. When two processes compute different digests for the same crate, both rustc runs write the same out-dir at once and delete or truncate each other's object files.The failed run's evidence shows how the digests diverged:
aws-lc-sysbuild-script action was a cache hit in one process and a miss in another, which re-ran it and produced different bytes, so every downstream digest (includingrustls) differed.PATH, giving a third set of digests.Non-reproducible inputs will keep producing such splits, so this change locks each declared output path instead of the digest. Actions without declared outputs still lock their digest. Identical actions still contend and reuse the cached result after waiting, because the same digest implies the same outputs. The locks are taken all-or-none, so a waiter never holds one lock while waiting for another.
Testing
cargo test -p once-cli --bins graph::analysis::actions(116 passed),cargo clippy -p once-cli --all-targets -- -D warnings,cargo fmt --all -- --check.