Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pHpjm-00048M-Ih for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Jan 2023 17:27:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pHpjl-0001OI-Di for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Jan 2023 17:27:05 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pHpjl-0001O9-4Y for pgsql-hackers@lists.postgresql.org; Tue, 17 Jan 2023 17:27:05 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pHpji-0005U8-Vj for pgsql-hackers@postgresql.org; Tue, 17 Jan 2023 17:27:04 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 30HHQvNl3044622; Tue, 17 Jan 2023 12:26:57 -0500 From: Tom Lane To: Andres Freund cc: Robert Haas , David Geier , vignesh C , Lukas Fittl , Michael Paquier , Ibrar Ahmed , Maciek Sakrejda , pgsql-hackers Subject: Re: Reduce timing overhead of EXPLAIN ANALYZE using rdtsc? In-reply-to: <20230117164758.gx4uuzhk5grw7zea@awork3.anarazel.de> References: <3eaeaa3a-b78e-ef0d-7319-5d713bbc09a0@gmail.com> <20230113195547.k4nlrmawpijqwlsa@awork3.anarazel.de> <20230117164758.gx4uuzhk5grw7zea@awork3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Tue, 17 Jan 2023 08:47:58 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3044620.1673976417.1@sss.pgh.pa.us> Date: Tue, 17 Jan 2023 12:26:57 -0500 Message-ID: <3044621.1673976417@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andres Freund writes: > Here's an updated version of the move to representing instr_time as > nanoseconds. It's now split into a few patches: I took a quick look through this. > 0001) Add INSTR_TIME_SET_ZERO() calls where otherwise 0002 causes gcc to > warn > Alternatively we can decide to deprecate INSTR_TIME_SET_ZERO() and > just allow to assign 0. I think it's probably wise to keep the macro. If we ever rethink this again, we'll be glad we kept it. Similarly, IS_ZERO is a good idea even if it would work with just compare-to-zero. I'm almost tempted to suggest you define instr_time as a struct with a uint64 field, just to help keep us honest about that. > 0003) Add INSTR_TIME_SET_SECOND() > This is used in 0004. Just allows setting an instr_time to a time in > seconds, allowing for a cheaper loop exit condition in 0004. Code and comments are inconsistent about whether it's SET_SECOND or SET_SECONDS. I think I prefer the latter, but don't care that much. > 0004) report nanoseconds in pg_test_timing Didn't examine 0004 in any detail, but the others look good to go other than these nits. regards, tom lane