pg_test_timing: Show additional TSC clock source debug info

In some cases its necessary to understand whether TSC frequency data was
sourced from CPUID, and which of the registers. Show this debug info at
the end of pg_test_timing, and rework TSC functions to support that.

This would have helped debug the buildfarm report fixed in 7fc36c5db550
and is likely going to aid in any TSC-related issues reported during the
beta period or later.

Additionally, emit a warning if TSC frequency from calibration differs
by more than 10% from the TSC frequency in use, and suggest the use
of timing_clock_source = 'system'.

In passing, add an explicit early return in the output function if the
loop count is zero. This can't happen in practice, but coverity complained
because we unconditionally call output for the fast TSC measurement.

Author: Lukas Fittl <[email protected]>
Suggested-by: Andres Freund <[email protected]>
Reviewed-by: Andres Freund <[email protected]>
Reviewed-by: Haibo Yan <[email protected]>
Reviewed-by: Tom Lane <[email protected]> (coverity fix only)
Discussion: 
https://postgr.es/m/cap53pkw3gzb+ktf5pu_o7tzbfz7+qm2m6udwugttjjzpv9y...@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5ba34f6dc838a1bc4415dc179be5bb2cf3b6d549

Modified Files
--------------
doc/src/sgml/ref/pgtesttiming.sgml      |  2 ++
src/bin/pg_test_timing/pg_test_timing.c | 55 ++++++++++++++++++++++++------
src/common/instr_time.c                 | 60 ++++++++++++++++++++++++++++++---
src/include/port/pg_cpu.h               |  2 +-
src/include/portability/instr_time.h    | 10 +++++-
src/port/pg_cpu_x86.c                   | 31 +++++++++++++++--
src/tools/pgindent/typedefs.list        |  1 +
7 files changed, 142 insertions(+), 19 deletions(-)

Reply via email to