Jan 23, 2026

Monotonic time is a frequently used, load bearing abstraction. Monotonicity is often enforced using the following code:

fn now(clock: *Clock) Instant {
const t_raw = os_time_monotonic();

const t = @max(t_raw, clock.guard);
assert(t >= clock.guard);
assert(t >= t_raw);

clock.guard = t;
return t;
}

That is, ask the OS about the current monotonic time, but don’t trust the result too much and clamp it using an in-process guard. Under normal scenarios, you can trust the OS promise of monotonicity, but, empirically, there’s a long tail of different scenarios where the promise isn’t upheld: https://github.com/rust-lang/rust/pull/56988

Today I realized that, if you are doing the above, you might as well force the time t…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help