4 ms·
There is no such thing as a monotonic clock on a regular computer. You need extra hardware for that (GPS, ...). All the regular Linux/Windows monotonic clocks
by 323 4y ago
There is no such thing as a monotonic clock on a regular computer. You need extra hardware for that (GPS, ...).
All the regular Linux/Windows monotonic clocks are broken in some scenarios and will go back or just not increase.
https://github.com/rust-lang/rust/pull/56988 https://github.com/rust-lang/rust/pull/56988
- rhn_mk1 4y agoA hardware timer is a monotonic clock, and at least one is built into any computer. With the advent of GPS spoofing, you can't really rely on GPS, either.
- touisteur 4y agoCan't wait for the miniaturisation of atomic clocks. They're quite already small but once they're 'so cheap they're on every SoC' a lot of ills of 'cheap' (as in not GC or AWS or Facebook) real-time distributed systems builders might go away.
- tech2 4y ago"not increasing" is a permissible interpretation of monotonic though. The clock should never go backward, but not increasing for a brief period is acceptable. It does mean you can't use it for 100% high-precision work, but at least you'll not be surprised by a negative result.
- touisteur 4y agoBut having a clock not progressing might break some wait- and timeout-based designs and you spend a lot of time understanding the strange phenomenon in a large fleet.
- the8472 4y agoThat PR is about buggy or niche systems. VMs lying about their clocks, CPUs with faulty firmware revisions, kernel bugs. Rust is just going the extra mile to uphold its guarantee even when the OS fails to do its job. It would have been legitimate to just say that in the face of broken systems you get broken behavior, GIGO, but it's difficult to convey that and most users aren't even aware that their systems are broken so it provided better user experience to paper over the bug rather than surfacing it. On most systems CLOCK_MONOTONIC actually is monotonic. It's not necessarily steady or providing SI seconds, but its monotonic. You'll need stuff like GPS if you want a monotonic, steady clock synchronized with other clocks.