Re: Proposal for enabling auto-vectorization for checksum calculations

From: Oleg Tselebrovskiy <o(dot)tselebrovskiy(at)postgrespro(dot)ru>
To: John Naylor <johncnaylorls(at)gmail(dot)com>
Cc: Andrew Kim <tenistarkim(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Proposal for enabling auto-vectorization for checksum calculations
Date: 2026-01-15 08:03:59
Message-ID: 0be1b7b05726652ea0d83e8f72fd4cfe@postgrespro.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Can't respond to the original message about v10 of the patch for some
reason, so I'll respond here.

> So in v10 I separated the body of checksum_block to
> a semi-private header to provide hardware-specific definitions
> for core code, while also maintaining the same one that
> external code expects

I like the usage of a semi-internal header, less code duplication
is always good

> In the attached v10-0003, I went back to something more similar to v6,
> but incorporated Andrew's idea of using PG_CHECKSUM_INTERNAL to allow
> for flexibility. Now pg_filedump compiles without any changes, so
> that's a plus.

If I understand correctly, with how code is currently,
external programms can define PG_CHECKSUM_INTERNAL manually,
but then they won't have access to static functions inside of
checksum.c, so all you get is a pointer that leads nowhere, correct?
I'd like to think that speeding up checksum calculation is something
that some external programms could appreciate.

Is it possible to move pg_checksum_block_fallback,
pg_checksum_block_avx2, and pg_checksum_choose to checksum_impl.h?
It would mean moving all the hardware check to the same header as well.
Doesn't look or sound pretty, but this would allow external programms
to chose implementation the same way the core does it, but also just
change nothing and still have fallback code.

> For this to be commitable, I think (and I think Oleg agrees) that the
> feature detection should go in src/port. Some of us have been thinking
> of refactoring and centralizing the feature detection, and now may be
> a good time to do it.

I do agree with that. I thought that we can continue with v10 as-is,
commit it with hardware checks still in checksum.c and refactor it with
everything else, but with my proposition above (and even without it)
it seems that refactoring of hardware checks should come first.

Also, not moving all those checksum files to src/port saves us from
thinking about problems with meson and current external programs,
but, I think, that after hardware checks are refactored, we could
revisit the question of moving checksum[_impl].h/.c to src/port.

All in all, very happy to see progress on this!

Regards,
Oleg

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-01-15 08:09:08 Re: Extended Statistics set/restore/clear functions.
Previous Message liujinyang 2026-01-15 07:58:36 Re: remove the unneeded header file math.h in binaryheap.c