pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Speed up tail processing when hashing aligned C strings
3+ messages / 2 participants
[nested] [flat]
* pgsql: Speed up tail processing when hashing aligned C strings
@ 2024-03-31 05:32 John Naylor <john.naylor@postgresql.org>
2024-03-31 06:05 ` Re: pgsql: Speed up tail processing when hashing aligned C strings John Naylor <johncnaylorls@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: John Naylor @ 2024-03-31 05:32 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Speed up tail processing when hashing aligned C strings
After encountering the NUL terminator, the word-at-a-time loop exits
and we must hash the remaining bytes. Previously we calculated the
terminator's position and re-loaded the remaining bytes from the input
string. We already have all the data we need in a register, so let's
just mask off the bytes we need and hash them immediately. The mask can
be cheaply computed without knowing the terminator's position. We still
need that position for the length calculation, but the CPU can now
do that in parallel with other work, shortening the dependency chain.
Ants Aasma and John Naylor
Discussion: https://postgr.es/m/CANwKhkP7pCiW_5fAswLhs71-JKGEz1c1%2BPC0a_w1fwY4iGMqUA%40mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/07f0f6abfc7f6c55cede528d9689dedecefc734a
Modified Files
--------------
src/include/common/hashfn_unstable.h | 44 ++++++++++++++++++++++++++++--------
1 file changed, 34 insertions(+), 10 deletions(-)
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pgsql: Speed up tail processing when hashing aligned C strings
2024-03-31 05:32 pgsql: Speed up tail processing when hashing aligned C strings John Naylor <john.naylor@postgresql.org>
@ 2024-03-31 06:05 ` John Naylor <johncnaylorls@gmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: John Naylor @ 2024-03-31 06:05 UTC (permalink / raw)
To: John Naylor <john.naylor@postgresql.org>; +Cc: pgsql-committers@lists.postgresql.org
On Sun, Mar 31, 2024 at 12:32 PM John Naylor <john.naylor@postgresql.org> wrote:
>
> Speed up tail processing when hashing aligned C strings
Skink reports valgrind error with
Conditional jump or move depends on uninitialised value(s)
I'll revert this soon to analyze, but first I'd like to see if any
big-endian animals have any issue.
^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Speed up tail processing when hashing aligned C strings, take tw
@ 2024-04-06 10:17 John Naylor <john.naylor@postgresql.org>
0 siblings, 0 replies; 3+ messages in thread
From: John Naylor @ 2024-04-06 10:17 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Speed up tail processing when hashing aligned C strings, take two
After encountering the NUL terminator, the word-at-a-time loop exits
and we must hash the remaining bytes. Previously we calculated
the terminator's position and re-loaded the remaining bytes from
the input string. This was slower than the unaligned case for very
short strings. We already have all the data we need in a register,
so let's just mask off the bytes we need and hash them immediately.
In addition to endianness issues, the previous attempt upset valgrind
in the way it computed the mask. Whether by accident or by wisdom,
the author's proposed method passes locally with valgrind 3.22.
Ants Aasma, with cosmetic adjustments by me
Discussion: https://postgr.es/m/CANwKhkP7pCiW_5fAswLhs71-JKGEz1c1%2BPC0a_w1fwY4iGMqUA%40mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/a365d9e2e8c1ead27203a4431211098292777d3b
Modified Files
--------------
src/include/common/hashfn_unstable.h | 46 ++++++++++++++++++++++++++++--------
1 file changed, 36 insertions(+), 10 deletions(-)
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2024-04-06 10:17 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-03-31 05:32 pgsql: Speed up tail processing when hashing aligned C strings John Naylor <john.naylor@postgresql.org>
2024-03-31 06:05 ` John Naylor <johncnaylorls@gmail.com>
2024-04-06 10:17 pgsql: Speed up tail processing when hashing aligned C strings, take tw John Naylor <john.naylor@postgresql.org>
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