Copilot commented on code in PR #60650:
URL: https://github.com/apache/doris/pull/60650#discussion_r2787110781
##########
be/src/util/hash_util.hpp:
##########
@@ -44,10 +45,78 @@ class HashUtil {
return (uint32_t)crc32(hash, (const unsigned char*)data, bytes);
}
+ // Inline CRC32 (zlib-compatible, standard CRC32 polynomial) for
fixed-size types.
+ // Uses Slicing-by-4 technique for 4/8-byte types: processes 4 bytes at a
time using
+ // 4 precomputed lookup tables, reducing serial table lookups from 4 to 1
per 4-byte chunk.
+ // Polynomial: 0xEDB88320 (reflected form of 0x04C11DB7).
+ // Endian note: CRC32 reflected algorithm processes bytes in address order
(byte[0] first).
+ // Slicing-by-4 requires byte[0] at LSB of the loaded uint32_t, which is
little-endian layout.
+ // LittleEndian::Load32 provides this on ALL platforms: noop on LE, bswap
on BE.
+ template <typename T>
+ static uint32_t zlib_crc32_fixed(const T& value, uint32_t hash) {
+ // Slicing-by-4 table: t[0] is the standard byte-at-a-time table,
+ // t[1..3] are extended tables for parallel 4-byte processing.
+ struct CRC32SliceBy4Table {
+ uint32_t t[4][256] {};
Review Comment:
`zlib_crc32_fixed` is a function template and defines `static constexpr
CRC32SliceBy4Table tbl` inside the template. This will instantiate (and
potentially emit) a separate 4x256 CRC table for every distinct `T` used across
the codebase, increasing compile time and binary size. Consider moving the
slice-by-4 table to a non-templated shared singleton (e.g., an
`inline`/`constinit` static in `HashUtil`, or a file-scope table) and have the
template reuse it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]