Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Oct 2005 18:33:19 +0100 (BST)
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Chuck Swiger <cswiger@mac.com>
Cc:        Poul-Henning Kamp <phk@phk.freebsd.dk>, David Xu <davidxu@freebsd.org>, current@freebsd.org
Subject:   Re: Timers and timing, was: MySQL Performance 6.0rc1
Message-ID:  <20051028183034.U3405@fledge.watson.org>
In-Reply-To: <43625ECE.7010804@mac.com>
References:  <32412.1130505646@critter.freebsd.dk> <436229CF.6040001@freebsd.org> <20051028144307.X53858@fledge.watson.org> <43625ECE.7010804@mac.com>

next in thread | previous in thread | raw e-mail | index | archive | help

On Fri, 28 Oct 2005, Chuck Swiger wrote:

>> I'm happy to take a stab at this.
>> 
>> We still need someone to grab the context switch time keeping by the 
>> horns and Do Something, though.
>
> If I understand what was said earlier, the getmicrotime() kernel 
> function ought to maintain the time at "(~ 1 msec)" precision.  Could 
> getmicrotime() be exported as a syscall, so that we could do something 
> like this:
>
> --- lib/libc/gen/time.c~        Fri Jul 18 22:53:46 2003
> +++ lib/libc/gen/time.c Fri Oct 28 13:04:26 2005
> @@ -47,7 +47,8 @@
>        struct timeval tt;
>        time_t retval;
>
> -       if (gettimeofday(&tt, (struct timezone *)0) < 0)
> +       getmicrotime(&tt);
> +       if (tt.tv_sec == 0)
>                retval = -1;
>        else
>                retval = tt.tv_sec;
>
> Note that this might even cause time(2) to return an error if the system 
> is using dummyclock, which could be considered a feature.  :-)

In the rwatson_clock branch in Perforce, I've added two new clocks to 
clock_gettime():

CLOCK_SECOND - getnanotime() with nanoseconds truncated
CLOCK_FUZZY - getnanotime() without nanoseconds truncated

I recognize that both names are badly chosen.  I'm compiling kernels to do 
a bit of benchmarking currently.

If we remove the call to nanotime() in the context switch, we may want to 
add a callout that calls nanotime() once each tick?  Or maybe 
automatically in the callout handler, so that any code running in a 
callout can use getnanotime() without having to worry about accuracy 
(much).

Robert N M Watson



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20051028183034.U3405>