pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nathan Bossart <nathan@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Optimize hex_encode() and hex_decode() using SIMD.
Date: Mon, 06 Oct 2025 17:29:57 +0000
Message-ID: <E1v5p25-000NOz-25@gemulon.postgresql.org> (raw)

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 <nathandbossart@gmail.com>
Co-authored-by: Chiranmoy Bhattacharya <chiranmoy.bhattacharya@fujitsu.com>
Co-authored-by: Susmitha Devanga <devanga.susmitha@fujitsu.com>
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
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(-)



Message-ID: <E1v5p25-000NOz-25@gemulon.postgresql.org>
Permalink:  ../E1v5p25-000NOz-25@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1v5p25-000NOz-25@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: nathan@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Optimize hex_encode() and hex_decode() using SIMD.
  In-Reply-To: <E1v5p25-000NOz-25@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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