Add concurrency-safe stale capture cleanup - #398
Closed
milyin wants to merge 1 commit into
Closed
Conversation
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
Adds an explicit, scoped
cargo prebindgen cleanoperation for the stale prebindgen payloads tracked by #397.This PR is stacked on #396 (
fix-201). #396 bounds JSONL growth inside one Cargo build output; this PR handles the remaining accumulation across multiple Cargo build hashes.build/<package>-<hash>/out/prebindgenand Cargo's newbuild/<package>/<hash>/out/prebindgenlayout across profiles and target triples--dry-run,--target-dir, repeatable--build-dir, and--manifest-path<package>-<hash>directories and every unrelated artifact intactBuild and concurrency safety
Cleanup is explicit, never automatic from
build.rs.Before mutation it non-blockingly acquires every discovered profile lock, in Cargo's order: current
.cargo-build-lockfirst, then compatibility.cargo-lock. If any profile is active, all locks are released and no capture is removed. This covers current shared/fine-grained locks, current exclusive locks, and Cargo 1.85's profile lock. Detected Linux NFS mounts are refused because Cargo skips these locks there.Each producer has two alternating state files outside
out/prebindgen, both tracked as rustc input dependencies. Cleanup durably advances the inactive slot before atomically renaming the capture to a tombstone. Therefore:Legacy captures created before this protocol are skipped; a one-time ordinary
cargo cleanis documented for those.Leakage test
Using one isolated target directory and
example-flatwith default,unstable,internal, and all features:cargo prebindgen clean: 0out/prebindgendirectoriesunstableagain: exactly that producer became Dirty because its state slot changed, recreated one valid capture, then remained Fresh and byte-stable on the next buildVerification
cargo +1.85.0 test -p prebindgen -p prebindgen-proc-macro --all-features --no-fail-fastcargo test --all --all-features --no-fail-fastcargo clippy --all-targets --all-features -- --deny warningsprebindgenrustdoc warnings checkcargo check --target aarch64-unknown-linux-gnu -p prebindgen --bin cargo-prebindgen./examples/regen-check.sh(all committed bindings byte-identical)example-cbindgenbuildCloses #397