Date: Sun, 27 Nov 2005 01:03:59 +0000 (GMT)
From: Robert Watson <rwatson at FreeBSD dot org>
To: src-committers at FreeBSD dot org, cvs-src at FreeBSD dot org, cvs-all at FreeBSD dot org
Subject: Re: cvs commit: src/sys/sys time.h src/sys/kern kern_time.c
Parts/Attachments:
   1 Shown     33 lines  Text
   2   OK    ~106 bytes  Text, ""
   3   OK    ~3.5 KB     Text, ""
----------------------------------------


On Sun, 27 Nov 2005, Robert Watson wrote:

>  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
> 
>  CLOCK_REALTIME_FAST             CLOCK_REALTIME
>  CLOCK_MONOTONIC_FAST            CLOCK_MONOTONIC
>  CLOCK_UPTIME_FAST               CLOCK_UPTIME
> 
>  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).

These changes are primarily intended to support the identification of
time-associated bottlenecks and allow experimentation with application
scoped reduction in quality of time use.  Attached is a small LD_PRELOAD
library to allow applications to be switched to the _FAST variants for
gettimeofday().  Build and install, then set:

  LD_PRELOAD=/usr/lib/libwrapper.so ; export LD_PRELOAD

This is not intended to be the last word in how this should be done -- more,
to facilitate some experimentation by providing some framework for
experimentation (i.e., a sample API and code to tweak applications).  I
expect that the details will be subject to substantial change. :-)

Robert N M Watson

Attachments:

Makefile
wrapper.c

Notes:

Run with either the environmental variable TIMEWRAPPER set to FAST or
PRECISE.  I.e., for csh:

  setenv TIMEWRAPPER FAST
  testprog

or for sh:

  TIMEWRAPPER=FAST
  export TIMEWRAPPER
  testprog