Suggestions on Avoiding syscall Overhead

Robert Watson rwatson at
Mon Apr 30 21:42:06 UTC 2007

On Mon, 30 Apr 2007, Dag-Erling Smørgrav wrote:

> Robert Watson <rwatson at> writes:
>> You didn't look at that CVS revision, did you?
> I did, but the relevant changes were lost in the noise of irrelevant Solaris 
> compatibility changes.

I've attached the commit message for reference here:

revision 1.71
date: 2005/11/27 00:55:18;  author: rwatson;  state: Exp;  lines: +8 -1
Add several aliases for existing clockid_t names to indicate that the
application wishes to request high precision time stamps be returned:

Alias                           Existing


Add experimental low-precision clockid_t names corresponding to these
clocks, but implemented using cached timestamps in kernel rather than
a full time counter query.  This offers a minimum update rate of 1/HZ,
but in practice will often be more frequent due to the frequency of
time stamping in the kernel:

New clockid_t name              Approximates existing clockid_t


Add one additional new clockid_t, CLOCK_SECOND, which returns the
current second without performing a full time counter query or cache
lookup overhead to make sure the cached timestamp is stable.  This is
intended to support very low granularity consumers, such as time(3).

The names, visibility, and implementation of the above are subject
to change, and will not be MFC'd any time soon.  The goal is to
expose lower quality time measurement to applications willing to
sacrifice accuracy in performance critical paths, such as when taking
time stamps for the purpose of rescheduling select() and poll()
timeouts.  Future changes might include retrofitting the time counter
infrastructure to allow the "fast" time query mechanisms to use a
different time counter, rather than a cached time counter (i.e.,

NOTE: With different underlying time mechanisms exposed, using
different time query mechanisms in the same application may result in
relative non-monoticity or the appearance of clock stalling for a
single clockid_t, as a cached time stamp queried after a precision
time stamp lookup may be "before" the time returned by the earlier
live time counter query.

Robert N M Watson
Computer Laboratory
University of Cambridge

More information about the freebsd-current mailing list