diff options
| author | Ali Saidi <alisaidi@amazon.com> | 2021-09-04 15:11:26 -0500 |
|---|---|---|
| committer | Ali Saidi <alisaidi@amazon.com> | 2021-09-04 15:11:26 -0500 |
| commit | ce450f893d551e25123e0bdb27acc9a85d15cb7f (patch) | |
| tree | 11d0266bdadd0c4e536cbd7666f2634141ae20de | |
| parent | 72a51c39c69256c8a8256e775f2764a1983048d4 (diff) | |
| download | rust-ce450f893d551e25123e0bdb27acc9a85d15cb7f.tar.gz rust-ce450f893d551e25123e0bdb27acc9a85d15cb7f.zip | |
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().
| -rw-r--r-- | library/std/src/time/monotonic.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/std/src/time/monotonic.rs b/library/std/src/time/monotonic.rs index fa96b7abff6..5783fa760df 100644 --- a/library/std/src/time/monotonic.rs +++ b/library/std/src/time/monotonic.rs @@ -5,7 +5,7 @@ pub(super) fn monotonize(raw: time::Instant) -> time::Instant { inner::monotonize(raw) } -#[cfg(all(target_has_atomic = "64", not(target_has_atomic = "128")))] +#[cfg(any(all(target_has_atomic = "64", not(target_has_atomic = "128")), target_arch = "aarch64"))] pub mod inner { use crate::sync::atomic::AtomicU64; use crate::sync::atomic::Ordering::*; @@ -70,7 +70,7 @@ pub mod inner { } } -#[cfg(target_has_atomic = "128")] +#[cfg(all(target_has_atomic = "128", not(target_arch = "aarch64")))] pub mod inner { use crate::sync::atomic::AtomicU128; use crate::sync::atomic::Ordering::*; |
