Inline SipHash::get128(char *)

The SipHash-128 values of the strings are calculated and stored in
a set when the UniqExact aggregate function is applied to a Column-
String, as the following snippet shows:

StringRef value = column.getDataAt(row_num);
UInt128 key;
SipHash hash;
hash.update(value.data, value.size);
hash.get128(key);

The implementation of SipHash requires an internal 8-byte buffer,
current_word (or current_bytes), for holding the input data in the
cross function calls of SipHash::update and SipHash::get128. But,
in the above situation, where the update and get128 only take place
once, the copy of input data to the buffer is unnecessary.

With get128 inlined, the compiler could optimize the code as a whole
and reduce the unexpected memory operations, and as a result, the
query performance is improved.
This commit is contained in:
Zhiguo Zhou 2023-07-11 21:51:05 +08:00
parent 49c1beb870
commit b0fb96c8b6

View File

@ -188,7 +188,7 @@ public:
/// Get the result in some form. This can only be done once!
void get128(char * out)
ALWAYS_INLINE void get128(char * out)
{
finalize();
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__