From: | Hironobu SUZUKI <hironobu(at)interdb(dot)jp> |
---|---|
To: | Michael Paquier <michael(at)paquier(dot)xyz> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [PATCH] Avoid unnecessary code execution in Instrument.c when TIMING is FALSE |
Date: | 2025-07-26 08:16:54 |
Message-ID: | b4d558d3-43af-4f77-91cf-f20d405cd9f7@interdb.jp |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2025/07/26 9:29, Michael Paquier wrote:
> On Sat, Jul 26, 2025 at 12:26:21AM +0900, Hironobu SUZUKI wrote:
>> Even when using EXPLAIN ANALYZE with TIMING=FALSE, the functions
>> InstrStopNode(), InstrEndLoop(), and InstrAggNode() in Instrument.c still
>> execute code related to the "starttime", "counter", "firsttuple", "startup",
>> and "total" fields within the Instrumentation structure.
>> These operations are unnecessary when timing is disabled, and since these
>> functions are called very frequently, I have created a patch to address
>> this.
>>
>> As far as I can tell, this change has no side effects and clarifies the
>> intent of each line, but please let me know if you notice any issues.
>
> Spoiler: this has been discussed during a meetup attended by most of
> the PostgreSQL hackers based in Tokyo and surroundings on the 18th of
> July, where Suzuki-san has noticed that the work done by the backend
> was pointless when using the instrumentation while hacking on an
> extension that relied at least on the explain hook. One of the
> remarks was that this seemed worth a submission to upstream when
> timers are disabled. The performance really took a hit when the timer
> was disabled, making the extension do a lot of unnecessary work for
> nothing.
> --
> Michael
Thanks for the spoilers!
Actually, I was confused while reading the Instrument module’s source
code since some sections ran even when timing was disabled, unlike
other parts guarded by if statements.
This patch mainly clarifies the coding intent, so I intentionally avoided
adding comments.
(The essential improvement proposals for internal monitoring will be
presented on another occasion.)
Best,
From | Date | Subject | |
---|---|---|---|
Next Message | Alexander Lakhin | 2025-07-26 09:00:01 | Re: stats.sql might fail due to shared buffers also used by parallel tests |
Previous Message | Alexander Pyhalov | 2025-07-26 07:56:22 | Re: Asynchronous MergeAppend |