Re: centralize CPU feature detection

From: John Naylor <johncnaylorls(at)gmail(dot)com>
To: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, root <tenistarkim(at)gmail(dot)com>, Nathan Bossart <nathandbossart(at)gmail(dot)com>
Subject: Re: centralize CPU feature detection
Date: 2026-02-19 12:19:30
Message-ID: CANWCAZZez5TX2fQH8Q_K312TC97O-dMQWJPUtLLGQRNBbcYuSQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Feb 19, 2026 at 1:47 AM Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> wrote:
>
> > Done. I haven't tried Arm support yet, but now I realize the header
> > should be named generically, so it's now "pg_cpu.h". Then it can be
> > included everywhere.
>
> That makes sense, and simplifies the usage of the header. (However,
> the include guard still refers to the old name)

Oops, fixed.

> > I don't know. The instruction family names are conventionally all in
> > caps, but this is just our signal that we've populated the array. That
> > said, a less generic name would better for grep-ability.
>
> Yes, that could work too. But reserving the lowercase "init" symbol in
> a very generic header seems like a bad idea (especially for a use case
> that isn't used globally), even if Postgres itself doesn't use the
> symbol for anything else. "INIT" at least would be unlikely to
> conflict with something else.

Still seems pretty generic, so I went with INIT_PG_X86.

I've also made a quick attempt at Arm support just to make sure I
didn't paint myself into a corner (v4-0005-6), and it compiles and
passes tests on a Debian aarch64 system with gcc 8.3. I'll put that
aside for later. v4-0001-3 are still the main focus now, and seem in
decent shape, maybe needs a bit more polish. (not to mention formal
commit messages)

--
John Naylor
Amazon Web Services

Attachment Content-Type Size
v4-0002-Centralize-detection-of-CPU-features.patch text/x-patch 9.7 KB
v4-0001-Rename-CRC-choose-files-for-future-general-purpos.patch text/x-patch 4.4 KB
v4-0003-Refactor-the-detection-of-ZMM-registers.patch text/x-patch 3.1 KB
v4-0004-Enable-autovectorizing-page-checksums-with-AVX2-w.patch text/x-patch 14.3 KB
v4-0005-Rename-CRC-Arm-v8-choose-file-for-future-general-.patch text/x-patch 3.7 KB
v4-0006-Centralize-detection-of-CPU-features-Arm-take-1.patch text/x-patch 7.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2026-02-19 12:24:00 Re: Skipping schema changes in publication
Previous Message Bertrand Drouvot 2026-02-19 12:03:32 Re: Adding locks statistics