Re: Use local buffer for packed numerics

From: David Geier <geidav(dot)pg(at)gmail(dot)com>
To: Andrei Lepikhov <lepihov(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-20 08:14:30
Message-ID: 3ef53e15-d98c-4a03-bb69-bd07bac344c4@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> It's attached. I saw really good results on x86 but some regressions on
> M5. That's why I started working on centralizing the case distinction
> work scattered throughout all the macros in set_var_from_num() and have
> all functions use that. This also makes the code a lot nicer. This
> change isn't complete yet, so I cannot send it to you.
>
> I'll share the results on my box with you tomorrow. Right now, I don't
> have access to my benchmark machine.

Attached are the results from my AMD Ryzen 7 9700X. You can see that
there are lots of speedups but also lots of regressions. The regressions
stem from the additional case distinction for if it's a packed /
unpacked varlena that are repeatedly scattered throughout the code via
the NUMERIC_ macros.

I also attached the benchmark script again. The version in my other mail
had a few small issues.

I also attached the patch that shows the idea of having all functions go
via init_var_from_num() and having all "parsing" code happen there in a
single place, only called once per function.

--
David Geier

Attachment Content-Type Size
v1-0001-Optimize-NUMERIC-by-having-all-code-go-through-in.patch text/x-patch 9.4 KB
numeric_results.txt text/plain 42.6 KB
numeric_benchmark.sql application/sql 15.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2026-11-20 08:15:53 Re: Assert "target_wal_endrec == divergerec" in pg_rewind
Previous Message Bertrand Drouvot 2026-11-20 08:10:21 Re: Report buffer access strategies in EXPLAIN