Thanks for sending both patchsets, and for running the numbers on all three architectures. I've read through the arithmetic patches. Moving numeric_build_result() out into its own function is a nice split. I also hadn't noticed the LCP stall from 16-bit immediates on x86. Good catch.
First I'll benchmark your arithmetic series against mine. I mostly want to know whether my uint64 multiply path for products of up to 4 digits gains enough to be worth keeping, or whether your simpler loop does just as well. After that I'll start a new thread for the fast short arithmetic and credit you there. The aggregate and HashAgg memory work can get its own thread later. Josh On Sat, Nov 28, 2026 at 9:08 AM Andrei Lepikhov <[email protected]> wrote: > > On 28/11/2026 02:08, Josh Hurst wrote: > > Would the arithmetic be worth pursuing separately? > Yes, by the way, I have the 'fast arithmetic' and 'fast aggregate' parts of > this > numeric speedup series of improvements too. Our arithmetic part looks pretty > similar, but aggregates are optimised a little differently. In the attachment, > both optimisations. > In my version, code is tuned by Claude to gain as much benefit as possible, > because it is designed to speed up a production ERP. Here is the performance > gain of the 'fast arithmetic' patchset: > > Change in execution time vs. master. gcc 14.2 -O2, 2M-row table, average of > three attempts for each query. > > Query Intel AMD Arm > ------------------------------------- ------ ------ ------ > count(v * q) -37% -28% -20% > count(v + q) -45% -35% -30% > count(*) WHERE v + q > v * 1.1 -52% -34% -29% > sum(price * (1 - disc) * (1 + tax)) -39% -22% -27% > TPC-H Q1 (data generated) -37% -22% -22% > sum(v * q), 500k groups -14% -9% -8% > > The aggregate part basically shows less interesting numbers in terms of > execution time, but it provides a nice reduction in memory consumption for > Hash > Aggregate: > > Query master patched change > ----------------------------------------- ------- ------- ------- > sum(v), 500k groups 192 MB 80 MB -58% > sum(w), 500k groups 240 MB 80 MB -67% > sum(x), 500k groups 240 MB 208 MB -13% > sum(v), 2M groups 744 MB 288 MB -61% > > v: numeric(12,2), q: numeric(8,3), w: numeric(30,6), x: 45 digits. > > It would be nice to continue work on these improvements. For now, no one in > the > community has said these improvements are worth the code changes required. So, > feel free to begin two new threads and use my version of the code, if it makes > sense. > > -- > regards, Andrei Lepikhov, > pgEdge
