The code has a nice explanation of the workaround they need to resort to to
ensure a monotonic time source.

https://doc.rust-lang.org/src/std/time.rs.html#157

        // And here we come upon a sad state of affairs. The whole point of
        // `Instant` is that it's monotonically increasing. We've found in
the
        // wild, however, that it's not actually monotonically increasing
for
        // one reason or another. These appear to be OS and hardware level
bugs,
        // and there's not really a whole lot we can do about them. Here's a
        // taste of what we've found:
        //
        // * #48514 - OpenBSD, x86_64
        // * #49281 - linux arm64 and s390x
        // * #51648 - windows, x86
        // * #56560 - windows, x86_64, AWS
        // * #56612 - windows, x86, vm (?)
        // * #56940 - linux, arm64
        // * https://bugzilla.mozilla.org/show_bug.cgi?id=1487778 - a
similar
        //   Firefox bug
        //
        // It simply seems that this it just happens so that a lot in the
wild
        // we're seeing panics across various platforms where consecutive
calls
        // to `Instant::now`, such as via the `elapsed` function, are
panicking
        // as they're going backwards. Placed here is a last-ditch effort
to try
        // to fix things up. We keep a global "latest now" instance which is
        // returned instead of what the OS says if the OS goes backwards.
        //
        // To hopefully mitigate the impact of this though a few platforms
are
        // whitelisted as "these at least haven't gone backwards yet".

In other words, 60% of the time it works every time.

-- 
You received this message because you are subscribed to the Google Groups 
"mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mechanical-sympathy+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to