Timers and timing, was: MySQL Performance 6.0rc1

Poul-Henning Kamp phk at phk.freebsd.dk
Fri Oct 28 10:51:01 PDT 2005


In message <20051028183034.U3405 at fledge.watson.org>, Robert Watson writes:

>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).

The timecounters already update the once every N hardclock ticks (search
for "tc_ticktock" and this happens before callouts are called.

The reason for the N divisor is to not needlessly burn CPU cycles on
systems with very high HZ.

For Hz up to and in cluding 1000, N=1 so every tick updates the timestamps
which get{bin,nano,micro}time() copies.

For Hz higher than 1000, N is set to attempt to update the timestamps
once per millisecond:

	tc_tick = (hz + 500) / 1000;

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.


More information about the freebsd-current mailing list