Consistently use Ordering::Relaxed for standalone atomic use cases (#14190)

This commit is contained in:
Christopher Tee 2025-06-24 15:30:26 -04:00 committed by GitHub
parent fe11ceedfa
commit 9fba7a4768
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 6 deletions

View file

@ -62,7 +62,7 @@ pub static RAYON_PARALLELISM: AtomicUsize = AtomicUsize::new(0);
/// `LazyLock::force(&RAYON_INITIALIZE)`.
pub static RAYON_INITIALIZE: LazyLock<()> = LazyLock::new(|| {
rayon::ThreadPoolBuilder::new()
.num_threads(RAYON_PARALLELISM.load(Ordering::SeqCst))
.num_threads(RAYON_PARALLELISM.load(Ordering::Relaxed))
.stack_size(min_stack_size())
.build_global()
.expect("failed to initialize global rayon pool");

View file

@ -13,12 +13,12 @@ pub static ENABLED: AtomicBool = AtomicBool::new(false);
/// Enable user-facing warnings.
pub fn enable() {
ENABLED.store(true, std::sync::atomic::Ordering::SeqCst);
ENABLED.store(true, std::sync::atomic::Ordering::Relaxed);
}
/// Disable user-facing warnings.
pub fn disable() {
ENABLED.store(false, std::sync::atomic::Ordering::SeqCst);
ENABLED.store(false, std::sync::atomic::Ordering::Relaxed);
}
/// Warn a user, if warnings are enabled.
@ -28,7 +28,7 @@ macro_rules! warn_user {
use $crate::anstream::eprintln;
use $crate::owo_colors::OwoColorize;
if $crate::ENABLED.load(std::sync::atomic::Ordering::SeqCst) {
if $crate::ENABLED.load(std::sync::atomic::Ordering::Relaxed) {
let message = format!("{}", format_args!($($arg)*));
let formatted = message.bold();
eprintln!("{}{} {formatted}", "warning".yellow().bold(), ":".bold());
@ -46,7 +46,7 @@ macro_rules! warn_user_once {
use $crate::anstream::eprintln;
use $crate::owo_colors::OwoColorize;
if $crate::ENABLED.load(std::sync::atomic::Ordering::SeqCst) {
if $crate::ENABLED.load(std::sync::atomic::Ordering::Relaxed) {
if let Ok(mut states) = $crate::WARNINGS.lock() {
let message = format!("{}", format_args!($($arg)*));
if states.insert(message.clone()) {

View file

@ -400,7 +400,7 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
}))?;
// Don't initialize the rayon threadpool yet, this is too costly when we're doing a noop sync.
uv_configuration::RAYON_PARALLELISM.store(globals.concurrency.installs, Ordering::SeqCst);
uv_configuration::RAYON_PARALLELISM.store(globals.concurrency.installs, Ordering::Relaxed);
debug!("uv {}", uv_cli::version::uv_self_version());