From 3de1b6c9a98993e6735098f94a7d5214d5fbcfcf Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 27 Oct 2025 16:34:35 -0700 Subject: [PATCH] std.Io.Threaded: better clock lowering for BSDs --- lib/std/Io/Threaded.zig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig index c3d1102fcc..dae9089e90 100644 --- a/lib/std/Io/Threaded.zig +++ b/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,