Re: What is a typical precision of gettimeofday()? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: What is a typical precision of gettimeofday()?
Date
Msg-id 3112460.1719940814@sss.pgh.pa.us
Whole thread Raw
In response to Re: What is a typical precision of gettimeofday()?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: What is a typical precision of gettimeofday()?
Re: What is a typical precision of gettimeofday()?
List pgsql-hackers
BTW, getting back to the original point of the thread: I duplicated
Hannu's result showing that on Apple M1 the clock tick seems to be
about 40ns.  But look at what I got with the v2 patch on my main
workstation (full output attached):

$ ./pg_test_timing
...
Per loop time including overhead: 16.60 ns
...
Timing durations less than 128 ns:
      ns   % of total  running %      count
      15       3.2738     3.2738    5914914
      16      49.0772    52.3510   88668783
      17      36.4662    88.8172   65884173
      18       9.5639    98.3810   17279249
      19       1.5746    99.9556    2844873
      20       0.0416    99.9972      75125
      21       0.0004    99.9976        757
...

It sure looks like this is exact-to-the-nanosecond results,
since the modal values match the overall per-loop timing,
and there are no zero measurements.

This is a Dell tower from 2021, running RHEL8 on an Intel Xeon W-2245.
Not exactly top-of-the-line stuff.

            regards, tom lane

Testing timing overhead for 3 seconds.
Per loop time including overhead: 16.60 ns
Histogram of timing durations:
   <= ns   % of total  running %      count
       0       0.0000     0.0000          0
       1       0.0000     0.0000          0
       3       0.0000     0.0000          0
       7       0.0000     0.0000          0
      15       3.2738     3.2738    5914914
      31      96.7241    99.9980  174753569
      63       0.0001    99.9981        265
     127       0.0001    99.9982        110
     255       0.0000    99.9982         29
     511       0.0000    99.9982          0
    1023       0.0013    99.9995       2410
    2047       0.0003    99.9999        586
    4095       0.0000    99.9999         10
    8191       0.0000    99.9999          3
   16383       0.0001   100.0000        228
   32767       0.0000   100.0000          1

Timing durations less than 128 ns:
      ns   % of total  running %      count
      15       3.2738     3.2738    5914914
      16      49.0772    52.3510   88668783
      17      36.4662    88.8172   65884173
      18       9.5639    98.3810   17279249
      19       1.5746    99.9556    2844873
      20       0.0416    99.9972      75125
      21       0.0004    99.9976        757
      22       0.0001    99.9978        252
      23       0.0001    99.9978        101
      24       0.0000    99.9979         50
      25       0.0000    99.9979         32
      26       0.0000    99.9979         28
      27       0.0000    99.9979         27
      28       0.0000    99.9979         19
      29       0.0000    99.9979         21
      30       0.0000    99.9980         34
      31       0.0000    99.9980         45
      32       0.0000    99.9980         42
      33       0.0000    99.9980         30
      34       0.0000    99.9980         17
      35       0.0000    99.9980         14
      36       0.0000    99.9980         13
      37       0.0000    99.9981         13
      38       0.0000    99.9981         13
      39       0.0000    99.9981         12
      40       0.0000    99.9981          8
      41       0.0000    99.9981         13
      42       0.0000    99.9981         12
      43       0.0000    99.9981          9
      44       0.0000    99.9981          9
      45       0.0000    99.9981          5
      46       0.0000    99.9981          3
      47       0.0000    99.9981          3
      48       0.0000    99.9981          5
      49       0.0000    99.9981          5
      50       0.0000    99.9981          4
      51       0.0000    99.9981          4
      52       0.0000    99.9981          2
      53       0.0000    99.9981          2
      54       0.0000    99.9981          2
      55       0.0000    99.9981          4
      56       0.0000    99.9981          1
      57       0.0000    99.9981          2
      58       0.0000    99.9981          2
      59       0.0000    99.9981          4
      60       0.0000    99.9981          2
      61       0.0000    99.9981          6
      62       0.0000    99.9981          2
      63       0.0000    99.9981          2
      64       0.0000    99.9981          2
      65       0.0000    99.9981          2
      66       0.0000    99.9981          2
      67       0.0000    99.9981          2
      72       0.0000    99.9981          1
      73       0.0000    99.9981          1
      74       0.0000    99.9981          1
      77       0.0000    99.9981          1
      78       0.0000    99.9981          2
      87       0.0000    99.9981          1
      91       0.0000    99.9981          1
      94       0.0000    99.9981          4
      95       0.0000    99.9981          3
      96       0.0000    99.9982         16
      97       0.0000    99.9982          5
      98       0.0000    99.9982          7
      99       0.0000    99.9982         14
     100       0.0000    99.9982         10
     101       0.0000    99.9982         10
     102       0.0000    99.9982          4
     103       0.0000    99.9982          2
     104       0.0000    99.9982          2
     105       0.0000    99.9982          1
     106       0.0000    99.9982          3
     107       0.0000    99.9982          1
     108       0.0000    99.9982          4
     109       0.0000    99.9982          4
     112       0.0000    99.9982          1
     115       0.0000    99.9982          2
     127       0.0000    99.9982          1

pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Set appropriate processing mode for auxiliary processes.
Next
From: Robert Haas
Date:
Subject: Re: On disable_cost