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 1pI85i-0000zT-9s for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Jan 2023 13:02:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pI85g-0008Im-Hw for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Jan 2023 13:02:56 +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 1pI85g-0008Ic-6s for pgsql-hackers@lists.postgresql.org; Wed, 18 Jan 2023 13:02:56 +0000 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pI85b-0007DZ-O3 for pgsql-hackers@postgresql.org; Wed, 18 Jan 2023 13:02:55 +0000 Received: by mail-ej1-x62e.google.com with SMTP id ud5so83101262ejc.4 for ; Wed, 18 Jan 2023 05:02:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=oz5wyZMl0l/qY52dSbz4DluuN8GS9KE8SOMF8JaH3F8=; b=KtGrFkjsetlm08b9hdowkeI5ZQ3NlUklHjl2epzxKtOVAUQYjLJ9pVykYrMDb2Bi3f xEQ2moDMOW2V2bA+O3odE7g3PtYXoMOuyOJ/5Mg8DhsEQV4mfV6qh5sHGJJODJIDCPLp jRgjJpy70DJzMRgJcKRyOnLJ2UvbS/k5YZtfkIEZuXJx3YDf91tb05ced60zDuB0S+AB G4FUNRMPh4B02D2H+ztQRvQLkFbzNc3xPqeMHoV+9cMzqxG95dHA1Z4u19m6lRcfWNEO gGKEwZPPWX/aFMQomq5wY6FLZl1lDmJ34yi9HGfEZdVJuNPeYIA/EzwgxfZi7W3F1qwo YiTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oz5wyZMl0l/qY52dSbz4DluuN8GS9KE8SOMF8JaH3F8=; b=hpYtjwrTxhZC0x32mYpn/WC9MVOGxgksJgU9bkySLDk33u1wavt4iRxcLkEVHHZsJ7 RQFaBB3P4A6UwsznUtDKWLw/p5AIxSwe7IJlGeM0pd0HdBrRpLqTaeNwrBQpOhy0Vvyq lnc1TLcJijxAhLGl1ztPGEUPGtaAGBT2AiPrSJNXjpzkYSeVCASHHHrYFvONdyvz3Gdm XqOFGaMpwS3TAV2IFj8jAW+NxP8j7tMTV2jidtFFumjJthAuJAX4CUcj/1cUw+jjwn6m T/aZSGkgIVCn/SdUDD6hX/TFx9Ra3wTau7A8s12autFejg4KMg4xTRgNDzSSqzRhETZL amdg== X-Gm-Message-State: AFqh2kpF7yQuGKaZRbyqIeAmryV01TI+s2KbFpCE2HXRSoQ2YUF98WXF c80vs5UQamo2gDWx+hRb9Lc= X-Google-Smtp-Source: AMrXdXuK8YHNyBv0NlHmugsDDkJKGyFgRlqbasGokohTDXMFP4EXkLlZZcXK3NZkBACrpiLn/DGreg== X-Received: by 2002:a17:906:f1d6:b0:86e:7896:80d4 with SMTP id gx22-20020a170906f1d600b0086e789680d4mr7025694ejb.49.1674046970237; Wed, 18 Jan 2023 05:02:50 -0800 (PST) Received: from [172.16.209.129] ([147.161.235.10]) by smtp.gmail.com with ESMTPSA id mb9-20020a170906eb0900b0084d34eec68esm13594323ejb.213.2023.01.18.05.02.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jan 2023 05:02:49 -0800 (PST) Message-ID: Date: Wed, 18 Jan 2023 14:02:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: Reduce timing overhead of EXPLAIN ANALYZE using rdtsc? Content-Language: en-US To: Andres Freund Cc: Michael Paquier , Ibrar Ahmed , Maciek Sakrejda , Lukas Fittl , pgsql-hackers References: <20200612232810.f46nbqkdhbutzqdg@alap3.anarazel.de> <20220701172639.ty4iu5almspueriu@alap3.anarazel.de> <3eaeaa3a-b78e-ef0d-7319-5d713bbc09a0@gmail.com> <20230116173723.exeijemoytfo2yc2@awork3.anarazel.de> From: David Geier In-Reply-To: <20230116173723.exeijemoytfo2yc2@awork3.anarazel.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 1/16/23 18:37, Andres Freund wrote: > Hi, > > On 2023-01-02 14:28:20 +0100, David Geier wrote: > > I'm doubtful this is worth the complexity it incurs. By the time we convert > out of the instr_time format, the times shouldn't be small enough that the > accuracy is affected much. I don't feel strong about it and you have a point that we most likely only convert ones we've accumulated a fair amount of cycles. > Looking around, most of the existing uses of INSTR_TIME_GET_MICROSEC() > actually accumulate themselves, and should instead keep things in the > instr_time format and convert later. We'd win more accuracy / speed that way. > > I don't think the introduction of pg_time_usec_t was a great idea, but oh > well. Fully agreed. Why not replacing pg_time_usec_t with instr_time in a separate patch? I haven't looked carefully enough if all occurrences could sanely replaced but at least the ones that accumulate time seem good starting points. >> Additionally, I initialized a few variables of type instr_time which >> otherwise resulted in warnings due to use of potentially uninitialized >> variables. > Unless we decide, as I suggested downthread, that we deprecate > INSTR_TIME_SET_ZERO(), that's unfortunately not the right fix. I've a similar > patch that adds all the necesarry INSTR_TIME_SET_ZERO() calls. I don't feel strong about it, but like Tom tend towards keeping the initialization macro. Thanks that you have improved on the first patch and fixed these issues in a better way. >> What about renaming INSTR_TIME_GET_DOUBLE() to INSTR_TIME_GET_SECS() so that >> it's consistent with the _MILLISEC() and _MICROSEC() variants? >> The INSTR_TIME_GET_MICROSEC() returns a uint64 while the other variants >> return double. This seems error prone. What about renaming the function or >> also have the function return a double and cast where necessary at the call >> site? > I think those should be a separate discussion / patch. OK. I'll propose follow-on patches ones we're done with the ones at hand. I'll then rebase the RDTSC patches on your patch set. -- David Geier (ServiceNow)