Re: Use local buffer for packed numerics

From: Andrei Lepikhov <lepihov(at)gmail(dot)com>
To: David Geier <geidav(dot)pg(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andreas Karlsson <andreas(at)proxel(dot)se>
Subject: Re: Use local buffer for packed numerics
Date: 2026-11-28 15:39:47
Message-ID: fcf01ac3-808c-4f5b-97ab-3ad744510112@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 19/11/2026 18:33, David Geier wrote:
>> I've attached a draft of part 2. It just handles = and <> without any unpacking.
>> Compared to master, it's typically ~30% faster with clang 19 and ~60% faster
>> with gcc. So, I guess it is a practical limit for your feature too.
>
> Could you run your changes against my benchmark script? Once only with
> the scratch buffer change and then combined with also avoiding the
> unpacking. You could do that exemplary just for a few operations. It
> would be great to talk about concrete, reproducible numbers. On that
> note: what architecture are you testing on?

Here are the benchmarking results on my side, as you requested.

I compared the current master branch and, separately, your patch, my unpack, and
all my four optimisations altogether (unpack, no unpack for EQ/NEQ [1], fast
path for arithmetic, and fast path for aggregates [2]).

My Intel MacBook Pro 2019 is not the best benchmarking platform already. So, I
usually use Google Cloud for such experiments.

I tried to choose different platforms (Intel/AMD/ARM) with the same compiler
(Clang). According to the Google docs, I used the following architectures: Intel
Xeon 8581C (1), AMD EPYC 9B45 (2), and ARM Neoverse-V2 (3). The total speedup is
as follows.

platform: (1) (2) (3)
master, ms 17926 15531 22211
avoid unpacking −6.1% −5.1% −6.6%
static buffer −5.2% −4.7% −4.3%
all four opts −8.8% −8.2% −7.5%

The exact numbers that your benchmark printed are in the attachment.

My personal lesson from this benchmark, in comparison to my own, is that each
optimisation has its own best case - and your benchmark doesn't cover all of
them. So, it definitely makes sense to consider each of these features separately.

[1]
https://www.postgresql.org/message-id/959ad09c-1d66-4260-9c2a-17b2dff03f14@gmail.com
[2]
https://www.postgresql.org/message-id/a3ed87e5-6d93-4694-ab57-76094b600938@gmail.com

--
regards, Andrei Lepikhov,
pgEdge

Attachment Content-Type Size
benchmarking.zip application/zip 26.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Ishjaap Singh 2026-11-28 15:37:51 Re: [PATCH] Improve tab completion for CREATE DOMAIN without AS