diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-02-13 06:44:12 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-13 06:44:12 +0100 |
| commit | 92613a25fc2c3a8f563025050c082f49b8a38019 (patch) | |
| tree | 9b8b24663eb72011d38964745866c24d3cd3e9c5 /src/test/codegen/src-hash-algorithm | |
| parent | 01c4c413012466214456767e6b013d036bbfeaea (diff) | |
| parent | 37a1fc542fbf8c11356d4395f28d4ab7f936945d (diff) | |
| download | rust-92613a25fc2c3a8f563025050c082f49b8a38019.tar.gz rust-92613a25fc2c3a8f563025050c082f49b8a38019.zip | |
Rollup merge of #89926 - the8472:saturate-instant, r=Mark-Simulacrum
make `Instant::{duration_since, elapsed, sub}` saturating and remove workarounds
This removes all mutex/atomic-based workarounds for non-monotonic clocks and makes the previously panicking methods saturating instead. Additionally `saturating_duration_since` becomes deprecated since `duration_since` now fills that role.
Effectively this moves the fixup from `Instant` construction to the comparisons.
This has some observable effects, especially on platforms without monotonic clocks:
* Incorrectly ordered Instant comparisons no longer panic in release mode. This could hide some programming errors, but since debug mode still panics tests can still catch them.
* `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.
* non-monotonic intervals will not be transitive, i.e. `b.duration_since(a) + c.duration_since(b) != c.duration_since(a)`
The upsides are reduced complexity and lower overhead of `Instant::now`.
## Motivation
Currently we must choose between two poisons. One is high worst-case latency and jitter of `Instant::now()` due to explicit synchronization; see #83093 for benchmarks, the worst-case overhead is > 100x. The other is sporadic panics on specific, rare combinations of CPU/hypervisor/operating system due to platform bugs.
Use-cases where low-overhead, fine-grained timestamps are needed - such as syscall tracing, performance profiles or sensor data acquisition (drone flight controllers were mentioned in a libs meeting) in multi-threaded programs - are negatively impacted by the synchronization.
The panics are user-visible (program crashes), hard to reproduce and can be triggered by any dependency that might be using Instants for any reason.
A solution that is fast _and_ doesn't panic is desirable.
----
closes #84448
closes #86470
Diffstat (limited to 'src/test/codegen/src-hash-algorithm')
0 files changed, 0 insertions, 0 deletions
