pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Lukas Fittl <lukas@fittl.com>
Cc: Haibo Yan <tristan.yim@gmail.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Cc: David Geier <geidav.pg@gmail.com>
Subject: Re: Reduce timing overhead of EXPLAIN ANALYZE using rdtsc?
Date: Sun, 12 Apr 2026 14:20:31 -0400
Message-ID: <343362.1776018031@sss.pgh.pa.us> (raw)
In-Reply-To: <CAP53Pkz7E1U6NDrdhHNeQk8qFTmQ=4N+LgZMpQ52jjxC8zMUCQ@mail.gmail.com>
References: <6wzsdvie5fvg427qti6icezycculhdr3vaykznbg27vtzzxa3p@hfk5m7cs5m4k>
	<CAP53Pkzdu_4xd0K5mFV+LeyWray0U_oFi3MRtTg+Oc3EOWpp5A@mail.gmail.com>
	<cuc74mdyyougmnvei4voqe4tzvotubgaibpdvs4limanpxnhve@vx4uzmvnz7ix>
	<CAP53PkyZ6sbaJvMHXFD4Xpv72ZtqUe8iz_02EquFDYjdKQ2=yw@mail.gmail.com>
	<CAP53Pkz-ixvTr4NBWuW5p66AybzGoKLAhYg4QSh=4pY7aVce6w@mail.gmail.com>
	<CAP53Pkx0xS7sdF05YkOsWmD-7CMtuEoqRT2oJipHDv7Yhy1ssA@mail.gmail.com>
	<jr4hk2sxhqcfpb67ftz5g4vw33nm67cgf7go3wwmqsafu5aclq@5m67ukuhyszz>
	<CAP53PkyMmUO=QbZPSc+uqSi+2pVjuEZc4MA45nKtLiZtNYf5NQ@mail.gmail.com>
	<26pttea74dz5gvsplaa4qsrwuytrza6g2mieqb7wxi4nnwb3cp@7uhq7zkfm6me>
	<CAP53PkwXBHQhpcW9k8PnUN+NZjVbmWwx7unehHxANBjD95a7Ow@mail.gmail.com>
	<npplam5gf5c6yrsaqjfdkdhz57czqrmbqlo2d7yud7uj76iozz@vuxdfa5hujzv>
	<CAP53PkwR8gEteMDTK0=hGx5YmLMUhW3aFXAergr_VWgmBFFBig@mail.gmail.com>
	<CAP53Pkx9aQ2oW1CCMQ6otNOAQEUKmUdmuJqpit9UQ_wTv99hCg@mail.gmail.com>
	<CABXr29HCf5RPr=4DOE42gRz_7EqPujBbvKHzzRLCjL6ghV_D=w@mail.gmail.com>
	<CAP53Pkz7E1U6NDrdhHNeQk8q! FTmQ=4N+LgZMpQ52jjxC8zMUCQ@mail.gmail.com>

Lukas Fittl <lukas@fittl.com> writes:
> FWIW, for archive's sake, drongo is green again now, thanks to commit
> 7fc36c5db550 (Avoid CPUID 0x15/0x16 for Hypervisor TSC frequency).

drongo may be happy, but Coverity is not:

166     	uint64		loop_count;
167     
168     	loop_count = test_timing(test_duration, TIMING_CLOCK_SOURCE_SYSTEM, false);
>>>     CID 1691465:         Incorrect expression  (DIVIDE_BY_ZERO)
>>>     In function call "output", division by expression "loop_count" which may be zero has undefined behavior.
169     	output(loop_count);

AFAICS it's correct to complain.  test_timing() visibly can return zero,
but of the three places where test_timing() is followed by output()
only one has a defense against that.

			regards, tom lane





view thread (172+ messages)  latest in thread

Message-ID: <343362.1776018031@sss.pgh.pa.us>
Permalink:  ../343362.1776018031@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/343362.1776018031@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, lukas@fittl.com, tristan.yim@gmail.com, andres@anarazel.de, geidav.pg@gmail.com
  Subject: Re: Reduce timing overhead of EXPLAIN ANALYZE using rdtsc?
  In-Reply-To: <343362.1776018031@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox