Re: Reduce timing overhead of EXPLAIN ANALYZE using rdtsc?

From: John Naylor <johncnaylorls(at)gmail(dot)com>
To: Lukas Fittl <lukas(at)fittl(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Jakub Wartak <jakub(dot)wartak(at)enterprisedb(dot)com>, Hannu Krosing <hannuk(at)google(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Ibrar Ahmed <ibrar(dot)ahmad(at)gmail(dot)com>, Maciek Sakrejda <m(dot)sakrejda(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, David Geier <geidav(dot)pg(at)gmail(dot)com>
Subject: Re: Reduce timing overhead of EXPLAIN ANALYZE using rdtsc?
Date: 2026-03-24 10:59:19
Message-ID: CANWCAZaAqg=vz3gkMndbn+MKA863Oy-Y-VJSSGP7gJ+vgTV1ew@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Mar 24, 2026 at 2:16 PM Lukas Fittl <lukas(at)fittl(dot)com> wrote:
>
> Hi John,
>
> On Mon, Mar 23, 2026 at 12:01 AM John Naylor <johncnaylorls(at)gmail(dot)com> wrote:
> > It's not that bad that the hard-coded indexes are in two places, but
> > it's also not necessary. I think "#define EAX 0 ...etc" is a fine,
> > straightforward increase in readability compared to what we have now,
> > and I don't see any downside. I suppose one argument in favor of the
> > struct is that it avoids declaring variables of type
> > array-of-4-unsigned in multiple places, but I think the array is fine,
> > and adding a new typedef is additional cognitive friction.
>
> Sounds good, lets do it that way - adjusted to use macros instead of a struct.

Looks good. The only thing that I would change is the single-letter
parameter/variable name "r". We could call it "reg" and it'd still be
pretty short. If you agree or have another suggestion, I can change
locally before pushing 0001 -- no need for a new patch set yet.

> > Speaking of signedness, why is the array of ints sometimes signed and
> > sometimes unsigned?
>
> The signedness is a MSVC-ism - I think its reasonable for us to work
> with unsigned integers in our code, and pass them by casting to
> __cpuid/__cpuidex (the MSVC variants).

CI works with this, so fine by me.

--
John Naylor
Amazon Web Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2026-03-24 11:14:53 Re: SQL Property Graph Queries (SQL/PGQ)
Previous Message Yugo Nagata 2026-03-24 10:57:27 Re: Allow to collect statistics on virtual generated columns