Repository navigation
fix: use AtomicUsize for AsyncStatus generation counter (#3045) - #3047
Open
santhiprakash wants to merge 1 commit into
Open
santhiprakash wants to merge 1 commit into
santhiprakash wants to merge 1 commit into
Conversation
santhiprakash
marked this pull request as ready for review
October 27, 2026 20:04
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.
This Pull Request fixes/closes #3045.
It changes the following:
AsyncStatus::generation(the status cache-invalidation counter) now usesstd::sync::atomic::AtomicUsizeinstead ofAtomicU64, which only exists on targets with 64-bit atomics and therefore broke the build on 32-bit targets (reported onpowerpc-apple-darwin;i686-unknown-linux-gnuand friends fail the same way).I followed the checklist:
make checkwithout errorsRoot cause
The
generationcounter is only a cache-invalidation token: it is loaded withOrdering::Relaxed, folded into the request key viahash(&(params, generation)), and bumped withfetch_add(1, Ordering::Relaxed)after each completed fetch.crate::hashis generic overT: Hashand produces theu64request key throughDefaultHasher::finish(), so nothing downstream assumes the counter is 64 bits wide.Fix
Switched the counter to
AtomicUsize— pointer-width atomics are available on every supported target, and the siblingpendingfield in the same struct already uses it. No new dependency is needed. A theoretical wrap at 2^32 on 32-bit targets is benign since the value is only an opaque token in the request hash. No behaviour change on 64-bit targets.Verification
There is no 32-bit CI job, so I verified against a real 32-bit target (
powerpc-unknown-linux-gnu, same class as the reporter'spowerpc-apple-darwin):cargo check --target powerpc-unknown-linux-gnu -p asyncgitfails witherror[E0432]: unresolved import std::sync::atomic::AtomicU64atasyncgit/src/status.rs:13asyncgitcleanlymake checkgreen:cargo fmt --check,cargo clippy --workspace --all-features,cargo nextest run --workspace(318/318 passed),tombi format --check,cargo deny checkNo unit tests were added since the change is a type substitution with identical runtime semantics; the existing workspace test suite continues to pass.