about summary refs log tree commit diff
path: root/library/std/src/time/monotonic.rs
AgeCommit message (Collapse)AuthorLines
2022-02-13make Instant::{duration_since, elapsed, sub} saturating and remove workaroundsThe8472-116/+0
This removes all mutex/atomics based workarounds for non-monotonic clocks and makes the previously panicking methods saturating instead. Effectively this moves the monotonization from `Instant` construction to the comparisons. This has some observable effects, especially on platforms without monotonic clocks: * Incorrectly ordered Instant comparisons no longer panic. This may hide some programming errors until someone actually looks at the resulting `Duration` * `checked_duration_since` will now return `None` in more cases. Previously it only happened when one compared instants obtained in the wrong order or manually created ones. Now it also does on backslides. The upside is reduced complexity and lower overhead of `Instant::now`.
2021-10-04Rollup merge of #88651 - AGSaidi:monotonize-inner-64b-aarch64, r=dtolnayManish Goregaokar-2/+2
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().
2021-09-17use AtomicU64::fetch_update instead of handrolled RMW-loopThe8472-14/+9
2021-09-16fix potential race in AtomicU64 time monotonizerThe8472-28/+34
2021-09-04Use the 64b inner:monotonize() implementation not the 128b one for aarch64Ali Saidi-2/+2
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().
2021-08-22Fix typos “an”→“a” and a few different ones that appeared in the ↵Frank Steffahn-1/+1
same search
2021-08-17[review] fix commentthe8472-1/+1
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2021-08-16correct overflows in the backslide case, add testThe8472-8/+30
2021-08-16Apply suggestions from code reviewthe8472-2/+2
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2021-08-13where available use 64- or 128bit atomics instead of a Mutex to monotonize timeThe8472-0/+93