Re: Timers and timing, was: MySQL Performance 6.0rc1

From: Robert Watson <rwatson_at_FreeBSD.org>
Date: Fri, 28 Oct 2005 22:32:31 +0100 (BST)
On Fri, 28 Oct 2005, David Xu wrote:

>>> On the other hand, a lower risk change might be to simply add a new 
>>> CLOCK_ type for lower resolution, and have a timer synchronize a 
>>> variable to the system clock once every 1/10 of a second.  This avoids 
>>> having to muck with VM layout, etc.
>> 
>> Is the CLOCK_* namespace ours to muck about with in the first place ?
>> 
> I prefer this way, can you implement it? The global page idea is a 
> complex, someone can slowly work on it, there are many things can be 
> done, for example, fast syscall using sysenter/sysexit.

Just as an experiment, I added two new time counters:

CLOCK_POOR - use a cached time returned by getnanotime(), which may be out
              of date by up to 10/hz (see phk's e-mail for the correct
              number).

CLOCK_SECOND - Same as CLOCK_POOR, only truncate the nanoseconds field to
                0, and return 1 second as the resolution via
                clock_getres().

Patch is attached.

Performance measurements on a P4 Xeon, dual processor with UP and SMP 
kernel configurations, no debugging.  Measured using 10,000 loops of each 
system call, 12 samples per clock type.  Measurements are in nanoseconds, 
measured using CLOCK_REALTIME, which has a resolution of 280ns reported 
via clock_getres().  Not surprisingly, the two above clocks measure about 
the same (they should do), and are a lot faster than real time 
measurements (they should be).  As currently implemented, gettimeofday() 
appears to cost the same as CLOCK_REALTIME.

It would be interesting to distribution of clock wrongness was, but I'm 
not set up to measure that currently.

Robert N M Watson

x 7UP/gettimeofday
+ 7UP/clock_gettime_poor
* 7UP/clock_gettime_realtime
% 7UP/clock_gettime_second
+--------------------------------------------------------------------------+
|       _at_                                                         *        |
|       _at_                                                         *        |
|       _at_                                                         *        |
|       _at_                                                         *        |
|+      _at_                                                         *        |
|_at_      _at_                                                        x*        |
|_at_%_at_   _at__at_                                                   x*   ***      *|
|  |__A_M|                                                     |_AA|_|     |
+--------------------------------------------------------------------------+
     N           Min           Max        Median           Avg        Stddev
x  12          1410          1507          1502       1493.75     26.574509
+  12           523           634           624     595.58333     47.586206
Difference at 95.0% confidence
         -898.167 +/- 32.632
         -60.1283% +/- 2.18457%
         (Student's t, pooled s = 38.5399)
*  12          1437          1627          1503     1507.6667     42.401401
No difference proven at 95.0% confidence
%  12           524           631           623           595     45.696628
Difference at 95.0% confidence
         -898.75 +/- 31.6491
         -60.1674% +/- 2.11877%
         (Student's t, pooled s = 37.379)



x 7SMP/gettimeofday
+ 7SMP/clock_gettime_poor
* 7SMP/clock_gettime_realtime
% 7SMP/clock_gettime_second
+--------------------------------------------------------------------------+
|_at_   _at_                                                                 * x*|
|_at_   _at_                                                                 * x*|
|_at_%  _at_%                                                                * x*|
|_at__at_  _at__at_                                                               **x**|
||MA_M                                                                 |AMM|
+--------------------------------------------------------------------------+
     N           Min           Max        Median           Avg        Stddev
x  12          1406          1443          1436     1425.4167     16.527984
+  12           503           566           517     527.08333     26.352362
Difference at 95.0% confidence
         -898.333 +/- 18.6239
         -63.0225% +/- 1.30656%
         (Student's t, pooled s = 21.9957)
*  12          1404          1450          1444     1430.0833     19.327128
No difference proven at 95.0% confidence
%  12           505           562           549         531.5     26.182923
Difference at 95.0% confidence
         -893.917 +/- 18.538
         -62.7127% +/- 1.30054%
         (Student's t, pooled s = 21.8943)

Received on Fri Oct 28 2005 - 19:32:32 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:46 UTC