postgresql/src/common
Andres Freund 5ba34f6dc8 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 7fc36c5db5
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 <lukas@fittl.com>
Suggested-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Haibo Yan <tristan.yim@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> (coverity fix only)
Discussion: https://postgr.es/m/CAP53Pkw3Gzb+KTF5pu_o7tzbfZ7+qm2m6uDWuGtTJjZpV9yNpg@mail.gmail.com
2026-05-16 11:51:34 -04:00
..
unicode Don't accept length of -1 in pg_locale.h APIs. 2026-05-15 11:09:15 -07:00
.gitignore Replace the data structure used for keyword lookup. 2019-01-06 17:02:57 -05:00
archive.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
base64.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
binaryheap.c Remove #include <math.h> where not needed 2026-01-15 19:09:47 +01:00
blkreftable.c Fix assorted places that need to use palloc_array(). 2026-05-11 05:13:46 -07:00
checksum_helper.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
compression.c Move tar detection and compression logic to common. 2026-03-20 15:31:35 -04:00
config_info.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
controldata_utils.c Don't include wait_event.h in pgstat.h 2026-03-06 16:24:58 +01:00
cryptohash.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
cryptohash_openssl.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
d2s.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
d2s_full_table.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
d2s_intrinsics.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
digit_table.h Change floating-point output format for improved performance. 2019-02-13 15:20:33 +00:00
encnames.c Fix comments for Korean encodings in encnames.c 2026-04-16 18:17:05 +12:00
exec.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
f2s.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
fe_memutils.c Make palloc_array() and friends safe against integer overflow. 2026-05-11 05:13:46 -07:00
file_perm.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
file_utils.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
hashfn.c Use fallthrough attribute instead of comment 2026-02-19 08:51:12 +01:00
hmac.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
hmac_openssl.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
instr_time.c pg_test_timing: Show additional TSC clock source debug info 2026-05-16 11:51:34 -04:00
ip.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
jsonapi.c Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
keywords.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
kwlookup.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
link-canary.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
logging.c Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
Makefile instrumentation: Standardize ticks to nanosecond conversion method 2026-04-07 13:00:24 -04:00
md5.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
md5_common.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
md5_int.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
meson.build instrumentation: Standardize ticks to nanosecond conversion method 2026-04-07 13:00:24 -04:00
parse_manifest.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
percentrepl.c Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
pg_get_line.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
pg_lzcompress.c Fix heap-buffer-overflow in pglz_decompress() on corrupt input. 2026-04-10 07:13:08 -04:00
pg_prng.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
pgfnames.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
psprintf.c Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
relpath.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
restricted_token.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
rmtree.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
ryu_common.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
saslprep.c Make implementation of SASLprep compliant for ASCII characters 2026-03-24 08:29:23 +09:00
scram-common.c Fix accidentally cast away qualifiers 2026-01-26 16:02:31 +01:00
sha1.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
sha1_int.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
sha2.c Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
sha2_int.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
sprompt.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
string.c Revert "Replace pg_restrict by standard restrict" 2026-01-14 15:12:25 +01:00
stringinfo.c Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
unicode_case.c Don't accept length of -1 in pg_locale.h APIs. 2026-05-15 11:09:15 -07:00
unicode_category.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
unicode_norm.c Prevent buffer overrun in unicode_normalize(). 2026-05-11 05:13:46 -07:00
username.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
wait_error.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
wchar.c Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00