pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nathan Bossart <nathandbossart@gmail.com>
To: John Naylor <johncnaylorls@gmail.com>
Cc: Devulapalli, Raghuveer <raghuveer.devulapalli@intel.com>
Cc: pgsql-hackers@lists.postgresql.org <pgsql-hackers@lists.postgresql.org>
Cc: Shankaran, Akash <akash.shankaran@intel.com>
Subject: Re: Improve CRC32C performance on SSE4.2
Date: Mon, 17 Feb 2025 11:41:09 -0600
Message-ID: <Z7N0tXyosn0QeUqS@nathan> (raw)
In-Reply-To: <CANWCAZb-3PZMwG3LvG_TcfuTZm3aRY7LgY-bO9-9tso=z0FgXQ@mail.gmail.com>
References: <CANWCAZYXk9xWrjEPNsm1oGYZ4CHBSVonn4XcCfWnusg+s_wiEA@mail.gmail.com>
	<PH8PR11MB828604A88A2E6C5EB5FF71E1FBFD2@PH8PR11MB8286.namprd11.prod.outlook.com>
	<CANWCAZZZWQc3VQauZ2bCPxDxKpjKbV7z=zntGu3zD1HgT76Fdw@mail.gmail.com>
	<PH8PR11MB82860A6C0E5C4B384B52E55AFBFC2@PH8PR11MB8286.namprd11.prod.outlook.com>
	<Z60QDnEuYptMjbQO@nathan>
	<PH8PR11MB82862F0F720DABB913AA31B3FBFC2@PH8PR11MB8286.namprd11.prod.outlook.com>
	<Z60aVnYHjxsh9XYo@nathan>
	<PH8PR11MB8286DABE98519B4A7C134EA7FBFC2@PH8PR11MB8286.namprd11.prod.outlook.com>
	<Z60eeem-RmEjzYwI@nathan>
	<CANWCAZb-3PZMwG3LvG_TcfuTZm3aRY7LgY-bO9-9tso=z0FgXQ@mail.gmail.com>

On Mon, Feb 17, 2025 at 05:58:01PM +0700, John Naylor wrote:
> I tried using branching for the runtime check, and this looks like the
> way to go:
> - Existing -msse4.2 builders will still call directly, but inside the
> function there is a length check and only for long input will it do a
> runtime check for pclmul.
> - This smooths the way for -msse4.2 (and the equivalent on Arm) to
> inline calls with short constant input (e.g. WAL insert lock),
> although I've not done that here.
> - This can be a simple starting point for consolidating runtime
> checks, as was proposed for popcount in the AVX-512 CRC thread, but
> with branching my model was Andres' sketch here:
> 
> https://www.postgresql.org/message-id/20240731023918.ixsfbeuub6e76one%40awork3.anarazel.de

Oh, nifty.  IIUC this should help avoid quite a bit of overhead even before
adding the PCLMUL stuff since it removes the function pointers for the
runtime-check builds.

While this needn't block this patch set, I do find the dispatch code to be
pretty complicated.  Maybe we can improve that in the future by using
macros to auto-generate much of it.  My concern here is less about this
particular patch set and more about the long term maintainability as we add
more and more stuff like it, each with its own tangled web of build and
dispatch rules.

-- 
nathan





view thread (82+ messages)  latest in thread

Message-ID: <Z7N0tXyosn0QeUqS@nathan>
Permalink:  ../Z7N0tXyosn0QeUqS@nathan/
Also on:    postgresql.org/message-id/Z7N0tXyosn0QeUqS@nathan

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: nathandbossart@gmail.com, johncnaylorls@gmail.com, raghuveer.devulapalli@intel.com, akash.shankaran@intel.com
  Subject: Re: Improve CRC32C performance on SSE4.2
  In-Reply-To: <Z7N0tXyosn0QeUqS@nathan>
  References: <CANWCAZYXk9xWrjEPNsm1oGYZ4CHBSVonn4XcCfWnusg+s_wiEA@mail.gmail.com> <PH8PR11MB828604A88A2E6C5EB5FF71E1FBFD2@PH8PR11MB8286.namprd11.prod.outlook.com> <CANWCAZZZWQc3VQauZ2bCPxDxKpjKbV7z=zntGu3zD1HgT76Fdw@mail.gmail.com> <PH8PR11MB82860A6C0E5C4B384B52E55AFBFC2@PH8PR11MB8286.namprd11.prod.outlook.com> <Z60QDnEuYptMjbQO@nathan> <PH8PR11MB82862F0F720DABB913AA31B3FBFC2@PH8PR11MB8286.namprd11.prod.outlook.com> <Z60aVnYHjxsh9XYo@nathan> <PH8PR11MB8286DABE98519B4A7C134EA7FBFC2@PH8PR11MB8286.namprd11.prod.outlook.com> <Z60eeem-RmEjzYwI@nathan> <CANWCAZb-3PZMwG3LvG_TcfuTZm3aRY7LgY-bO9-9tso=z0FgXQ@mail.gmail.com> <Z7N0tXyosn0QeUqS@nathan>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox