Optimize hex_encode() and hex_decode() using SIMD.

The hex_encode() and hex_decode() functions serve as the workhorses
for hexadecimal data for bytea's text format conversion functions,
and some workloads are sensitive to their performance.  This commit
adds new implementations that use routines from port/simd.h, which
testing indicates are much faster for larger inputs.  For small or
invalid inputs, we fall back on the existing scalar versions.
Since we are using port/simd.h, these optimizations apply to both
x86-64 and AArch64.

Author: Nathan Bossart <[email protected]>
Co-authored-by: Chiranmoy Bhattacharya <[email protected]>
Co-authored-by: Susmitha Devanga <[email protected]>
Reviewed-by: John Naylor <[email protected]>
Discussion: https://postgr.es/m/aLhVWTRy0QPbW2tl%40nathan

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ec8719ccbfcd78c6b40b5f2b94f60769f3bd08aa

Modified Files
--------------
src/backend/utils/adt/encode.c        | 137 +++++++++++++++++++++-
src/include/port/simd.h               | 211 ++++++++++++++++++++++++++++++++++
src/test/regress/expected/strings.out |  58 ++++++++++
src/test/regress/sql/strings.sql      |  16 +++
4 files changed, 418 insertions(+), 4 deletions(-)

Reply via email to