Re: Proposal for Updating CRC32C with AVX-512 Algorithm.

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: "Amonson, Paul D" <paul(dot)d(dot)amonson(at)intel(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "Shankaran, Akash" <akash(dot)shankaran(at)intel(dot)com>
Subject: Re: Proposal for Updating CRC32C with AVX-512 Algorithm.
Date: 2024-08-26 19:32:12
Message-ID: ZszYPB3KxKsBexga@nathan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Aug 26, 2024 at 07:15:47PM +0000, Amonson, Paul D wrote:
>> +#define COMP_CRC32C_SMALL(crc, data, len) \
>> + ((crc) = pg_comp_crc32c_sse42((crc), (data), (len)))
>>
>> My interpretation of Andres's upthread suggestion is that we'd add the length
>> check within the macro instead of introducing a separate one. We'd expect
>> the compiler to optimize out comparisons for small lengths known at compile
>> time and always call the existing implementation (which may still involve a
>> function pointer in most cases).
>
> How does the m4/compiler know the difference between a const "len" and a
> dynamic "len"? I already when the code and changed constant sizes
> (structure sizes) to the new macro. Can you give an example of how this
> could work?

Things like sizeof() and offsetof() are known at compile time, so the
compiler will recognize when a condition is always true or false and
optimize it out accordingly. In cases where the value cannot be known at
compile time, checking the length in the macro and dispatching to a
different implementation may still be advantageous, especially when the
different implementation doesn't involve function pointers.

--
nathan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2024-08-26 19:44:11 Re: allowing extensions to control planner behavior
Previous Message John H 2024-08-26 19:31:53 Re: Allow logical failover slots to wait on synchronous replication