Time to move pg_test_timing to measure in nanoseconds
Time to move pg_test_timing to measure in nanoseconds
Currently pg_test_timing utility measures its timing overhead in
microseconds, giving results like this
~$ /usr/lib/postgresql/15/bin/pg_test_timing
Testing timing overhead for 3 seconds.
Per loop time including overhead: 18.97 ns
Histogram of timing durations:
< us % of total count
1 98.11132 155154419
2 1.88756 2985010
4 0.00040 630
8 0.00012 184
16 0.00058 919
32 0.00003 40
64 0.00000 6
I got curious and wanted to see how the 98.1% timings are distributed
(raw uncleaned patch attached)
And this is what I got when I increased the measuring resolution to nanoseconds
hannuk@hannuk1:~/work/postgres15_uni_dist_on/src/bin/pg_test_timing$
./pg_test_timing
Testing timing overhead for 3 seconds.
Per loop time including overhead: 17.34 ns, min: 15, same: 0
Histogram of timing durations:
< ns % of total count
1 0.00000 0
2 0.00000 0
4 0.00000 0
8 0.00000 0
16 1.14387 1979085
32 98.47924 170385392
64 0.21666 374859
128 0.15654 270843
256 0.00297 5139
512 0.00016 272
1024 0.00004 73
2048 0.00018 306
4096 0.00022 375
8192 0.00006 99
16384 0.00005 80
32768 0.00001 20
65536 0.00000 6
131072 0.00000 2
As most of the samples seems to be in ranges 8..15 and 16..32
nanoseconds the current way of measuring at microsecond resolution is
clearly inadequate.
The attached patch is not meant to be applied as-is but is rather
there as a helper to easily verify the above numbers.
QUESTIONS
1. Do you think it is ok to just change pg_test_timing to return the
result in nanoseconds or should there be a flag that asks for
nanosecond resolution ?
2. Should the output be changed to give ranges instead of `Re: Time to move pg_test_timing to measure in nanoseconds
От:
Andres Freund <andres@anarazel.de>
Дата:
Hi, On 2023-03-26 16:43:21 +0200, Hannu Krosing wrote: > Currently pg_test_timing utility measures its timing overhead in > microseconds, giving results like this I have a patch that does that and a bit more that's included in a larger patchset by David Geier: https://postgr.es/m/198ef658-a5b7-9862-2017-faf85d59e3a8%40gmail.com Could you review that part of the patchset? Greetings, Andres Freund
Re: Time to move pg_test_timing to measure in nanoseconds
От:
Hannu Krosing <hannuk@google.com>
Дата:
Sure, will do. On Sun, Mar 26, 2023 at 11:40 PM Andres Freund wrote: > > Hi, > > On 2023-03-26 16:43:21 +0200, Hannu Krosing wrote: > > Currently pg_test_timing utility measures its timing overhead in > > microseconds, giving results like this > > I have a patch that does that and a bit more that's included in a larger > patchset by David Geier: > https://postgr.es/m/198ef658-a5b7-9862-2017-faf85d59e3a8%40gmail.com > > Could you review that part of the patchset? > > Greetings, > > Andres Freund