proof-of-concept patch for cpu accounting speedup

Poul-Henning Kamp phk at phk.freebsd.dk
Mon Nov 28 22:11:29 GMT 2005


http://phk.freebsd.dk/patch/context_time.patch

This is just a proof of concept, it doesn't have all the tricky bits for
determining max TSC rate on machines where the cpu clock is fiddled with
and it doesn't have a fallback for machines without TSC etc etc.

But in your average i386 (and probably amd64) system it should work.


I am very interested to hear feedback and benchmarks of this patch.

The two most critical measurements are:
   *  "how does it affect workloads which do many context switches"
and
   *  "how does this affect CPU time accounting."

To measure the latter, make absolutely sure your machine doesn't play
power saving tricks with the TSC/cpu clock.


A quick sanity check reveals no obvious bogons in cpu time accounting
and unixbench's context1 switch shows 23% improvement on my testbox:

x _reference
+ _patched
+--------------------------------------------------------------------------+
|x  xx x                                                      +      ++  ++|
| |_AM_|                                                         |____A___||
+--------------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x   5         48370         49433         48997       48959.8     380.65693
+   5         59107         61079         60536       60376.4     786.45458
Difference at 95.0% confidence
        11416.6 +/- 901.059
        23.3183% +/- 1.84041%
        (Student's t, pooled s = 617.823)



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