Commit 3de1b6c9a9

Andrew Kelley <andrew@ziglang.org>
2025-10-28 00:34:35
std.Io.Threaded: better clock lowering for BSDs
1 parent 80a341b
Changed files (1)
lib
lib/std/Io/Threaded.zig
@@ -5009,7 +5009,12 @@ fn clockToPosix(clock: Io.Clock) posix.clockid_t {
             // On freebsd derivatives, use MONOTONIC_FAST as currently there's
             // no precision tradeoff.
             .freebsd, .dragonfly => posix.CLOCK.MONOTONIC_FAST,
-            else => posix.CLOCK.BOOTTIME,
+            // On linux, use BOOTTIME instead of MONOTONIC as it ticks while
+            // suspended.
+            .linux => posix.CLOCK.BOOTTIME,
+            // On other posix systems, MONOTONIC is generally the fastest and
+            // ticks while suspended.
+            else => posix.CLOCK.MONOTONIC,
         },
         .cpu_process => posix.CLOCK.PROCESS_CPUTIME_ID,
         .cpu_thread => posix.CLOCK.THREAD_CPUTIME_ID,