QUARK_GET_BOOTTIME(3) Library Functions Manual QUARK_GET_BOOTTIME(3)

quark_get_boottime — get the boottime epoch for wallclock translation

#include <quark.h>

u64
quark_get_boottime(void);

quark_get_boottime returns the boottime epoch: the wallclock time of boot in nanoseconds since the Unix epoch, computed as the difference of CLOCK_REALTIME and CLOCK_BOOTTIME. This is the same value the kernel exposes as the btime field of /proc/stat, but in nanosecond instead of one second resolution. Truncating it to whole seconds yields btime exactly, for users that must agree with tools deriving wallclock from btime, as the procps utilities do.

Adding the epoch to a nanoseconds-since-boot timestamp yields nanoseconds since the Unix epoch:

u64 epoch = quark_get_boottime();

for each event
	wallclock = event_time + epoch;

Times since boot are immune to system clock changes, wallclock times are not: translate at the last moment, when a time leaves the system for display or storage. Gradual clock corrections (slewing) adjust the wallclock and the boot clock at the same rate, leaving the epoch untouched, only a step moves it, as when NTP corrects a clock that was wrong at boot.

The epoch is sampled at most every 10ms, regardless of how frequently this function gets called, and a new sample is only adopted when it strays more than 10ms from the previously adopted one: only an actual clock step moves the epoch that much, anything below is sampling noise that would jitter conversions from call to call. Successive calls return the same value absent a clock step. A call costs little more than a clock read, fetching it once per batch of events is the recommended pattern, and the Go bindings depend on it to avoid a cgo call per event.

quark_get_boottime may be called from any thread without synchronization.

The boottime epoch in nanoseconds since the Unix epoch. Zero is returned if the epoch could not be sampled, which should not happen on a functioning system.

quark_event_dump(3), quark_process_iter(3), quark_process_lookup(3), quark_queue_block(3), quark_queue_close(3), quark_queue_default_attr(3), quark_queue_get_epollfd(3), quark_queue_get_event(3), quark_queue_get_stats(3), quark_queue_open(3), quark(7), quark-btf(8), quark-mon(8), quark-test(8)

quark_get_boottime appeared in quark 0.8, when times handed out by quark switched from nanoseconds since the Unix epoch to nanoseconds since boot. In quark 0.9 it became self-maintaining and gained nanosecond resolution, replacing quark_update_boottime() and quark_time_to_wallclock().

September 24, 2026 Linux