TECHNOLOGY

Linux suspend-aware expiry: CLOCK_MONOTONIC can leave an old input looking young

In this article
THE QUICK TAKE

Use the clock whose suspend semantics match the freshness requirement, then separately define wakeup and post-resume admission; clock selection alone does not schedule execution.

A resumed assistant accepts an old observation

A laptop assistant queues a local sensor observation before the machine suspends. On resume, it checks freshness using a clock that excluded suspended time and treats the old input as recent. The clock may be behaving correctly while the freshness policy is wrong for the application. Decide whether validity means elapsed time experienced by the owner or only time while the system was active. That choice must precede the timer implementation and any claim that queued observations remain suitable for inference.

Linux monotonic clocks have different suspend semantics

The clock_gettime manual distinguishes CLOCK_MONOTONIC, which excludes system suspend, from CLOCK_BOOTTIME, which includes it. Both serve duration-oriented purposes but answer different questions across sleep. Do not replace the choice with CLOCK_REALTIME merely because its displayed calendar time advanced; wall-clock changes introduce another contract. Store the chosen clock and unit with the acquisition observation and expiry rule, and compare values from compatible domains rather than combining whichever timestamps are easiest to retrieve.

Counting suspend does not wake the computer

The timerfd manual separately documents BOOTTIME and alarm variants that can wake a suspended system under the required capability. A suspend-aware expiry clock does not itself reserve wakeup authority or CPU execution. If expiry only needs enforcement when the assistant next runs, a post-resume admission check can reject stale work. If a real wakeup is required, qualify the supported timer, capability and hardware path separately. Never infer a wakeup guarantee from the word boottime alone.

Recheck before publishing resumed work

A request can pass freshness before suspend and still become obsolete before its eventual result is used. Define the application’s validation points: before starting expensive work, before publishing a time-sensitive result, or both. Preserve the original acquisition identity when retrying instead of resetting its age at resume. A model’s generated answer may be internally plausible while describing a condition that no longer applies. The clock can establish age under the chosen definition; it cannot determine semantic validity without the application’s source policy.

Propose an active-versus-suspended fixture

Use harmless time-stamped inputs and compare a controlled active interval with a supported suspend/resume interval. Retain both relevant clock deltas, actual resume observation and the chosen input-admission outcome. Test an input expiring during suspend without requiring it to trigger a wakeup. If alarm behavior is separately claimed, validate that path independently. Acceptance requires the intended freshness decision, not identical deltas from different clocks. No machine was suspended or wake timer armed here; this is a proposed semantic check.

Report expiry separately from measured inference time

Monotonic latency measurement preserves clock domains. Remaining request budgets preserve work-admission boundaries. Add explicit suspend semantics and wakeup requirements for local devices. This explains why an observation can expire while no inference runs and why an expired timer does not necessarily mean the system woke. A defensible report distinguishes input age, scheduling delay and actual processing without presenting one generic monotonic duration as all of them.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles