News for hackers. Stuff that matters.
Re:Determine durations with monotonic clocks if available by 323 on Monday January 30, 2023 @04:46AM (#34577720)
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

Re:Determine durations with monotonic clocks if available by rhn_mk1 on Monday January 30, 2023 @05:25AM (#34577973)
A 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.
Re:Determine durations with monotonic clocks if available by touisteur on Monday January 30, 2023 @01:22PM (#34584087)
Can'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.
Re:Determine durations with monotonic clocks if available by tech2 on Monday January 30, 2023 @06:03AM (#34578214)
"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.
Re:Determine durations with monotonic clocks if available by touisteur on Monday January 30, 2023 @01:20PM (#34584057)
But 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.
Re:Determine durations with monotonic clocks if available by the8472 on Monday January 30, 2023 @07:48AM (#34578958)
That 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.