Skip to content

Commit dc26b5f

Browse files
authored
Rollup merge of rust-lang#88651 - AGSaidi:monotonize-inner-64b-aarch64, r=dtolnay
Use the 64b inner:monotonize() implementation not the 128b one for aarch64 aarch64 prior to v8.4 (FEAT_LSE2) doesn't have an instruction that guarantees untorn 128b reads except for completing a 128b load/store exclusive pair (ldxp/stxp) or compare-and-swap (casp) successfully. The requirement to complete a 128b read+write atomic is actually more expensive and more unfair than the previous implementation of monotonize() which used a Mutex on aarch64, especially at large core counts. For aarch64 switch to the 64b atomic implementation which is about 13x faster for a benchmark that involves many calls to Instant::now().
2 parents d1a40d7 + ce450f8 commit dc26b5f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/std/src/time/monotonic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub(super) fn monotonize(raw: time::Instant) -> time::Instant {
55
inner::monotonize(raw)
66
}
77

8-
#[cfg(all(target_has_atomic = "64", not(target_has_atomic = "128")))]
8+
#[cfg(any(all(target_has_atomic = "64", not(target_has_atomic = "128")), target_arch = "aarch64"))]
99
pub mod inner {
1010
use crate::sync::atomic::AtomicU64;
1111
use crate::sync::atomic::Ordering::*;
@@ -71,7 +71,7 @@ pub mod inner {
7171
}
7272
}
7373

74-
#[cfg(target_has_atomic = "128")]
74+
#[cfg(all(target_has_atomic = "128", not(target_arch = "aarch64")))]
7575
pub mod inner {
7676
use crate::sync::atomic::AtomicU128;
7777
use crate::sync::atomic::Ordering::*;

0 commit comments

Comments
 (0)