Re: [PATCH] Hex-coding optimizations using SVE on ARM.

From: John Naylor <johncnaylorls(at)gmail(dot)com>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: "Chiranmoy(dot)Bhattacharya(at)fujitsu(dot)com" <Chiranmoy(dot)Bhattacharya(at)fujitsu(dot)com>, "Devanga(dot)Susmitha(at)fujitsu(dot)com" <Devanga(dot)Susmitha(at)fujitsu(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, "Ragesh(dot)Hajela(at)fujitsu(dot)com" <Ragesh(dot)Hajela(at)fujitsu(dot)com>
Subject: Re: [PATCH] Hex-coding optimizations using SVE on ARM.
Date: 2025-01-14 05:27:30
Message-ID: CANWCAZZvXuJMgqMN4u068Yqa19CEjS31tQKZp_qFFFbgYfaXqQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Jan 11, 2025 at 3:46 AM Nathan Bossart <nathandbossart(at)gmail(dot)com> wrote:
>
> I was able to get auto-vectorization to take effect on Apple clang 16 with
> the following addition to src/backend/utils/adt/Makefile:
>
> encode.o: CFLAGS += ${CFLAGS_VECTORIZE} -mllvm -force-vector-width=8
>
> This gave the following results with your hex_encode_test() function:
>
> buf | HEAD | patch | % diff
> -------+-------+-------+--------
> 16 | 21 | 16 | 24
> 64 | 54 | 41 | 24
> 256 | 138 | 100 | 28
> 1024 | 441 | 300 | 32
> 4096 | 1671 | 1106 | 34
> 16384 | 6890 | 4570 | 34
> 65536 | 27393 | 18054 | 34

We can do about as well simply by changing the nibble lookup to a byte
lookup, which works on every compiler and architecture:

select hex_encode_test(1000000, 1024);
master:
Time: 1158.700 ms
v2:
Time: 777.443 ms

If we need to do much better than this, it seems better to send the
data to the client as binary, if possible.

--
John Naylor
Amazon Web Services

Attachment Content-Type Size
v2-byte-lookup.patch text/x-patch 1.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-01-14 05:40:40 Re: [PATCH] Hex-coding optimizations using SVE on ARM.
Previous Message Amit Kapila 2025-01-14 04:57:07 Re: Conflict Detection and Resolution