Re: Optimising numeric division - Mailing list pgsql-hackers

From Joel Jacobson
Subject Re: Optimising numeric division
Date
Msg-id 0ecb9e14-b979-47a2-a403-b600e561dc22@app.fastmail.com
Whole thread Raw
In response to Re: Optimising numeric division  ("Joel Jacobson" <joel@compiler.org>)
List pgsql-hackers
On Sat, Aug 24, 2024, at 14:10, Dean Rasheed wrote:
> On Sat, 24 Aug 2024 at 08:26, Joel Jacobson <joel@compiler.org> wrote:
>>
>> On Sat, Aug 24, 2024, at 01:35, Joel Jacobson wrote:
>> > On Sat, Aug 24, 2024, at 00:00, Joel Jacobson wrote:
>> >> Since statistical tools that rely on normal distributions can't be used,
>> >> let's look at the individual measurements for (var1ndigits=3, var2ndigits=3)
>> >> since that seems to be the biggest slowdown on both CPUs,
>> >> and see if our level of surprise is affected.
>> >
>> > Here is a more traditional benchmark,
>> > which seems to also indicate (var1ndigits=3, var2ndigits=3) is a bit slower:
>>
>> I tested just adding back div_var_int64, and it seems to help.
>>
>
> Thanks for testing.
>
> There does appear to be quite a lot of variability between platforms
> over whether or not div_var_int64() is a win for 3 and 4 digit
> divisors. Since this patch is primarily about improving div_var()'s
> long division algorithm, it's probably best for it to not touch that,
> so I've put div_var_int64() back in for now. We could possibly
> investigate whether it can be improved separately.
>
> Looking at your other test results, they seem to confirm my previous
> observation that exact mode is faster than approximate mode for
> var2ndigits <= 12 or so, so I've added code to do that.
>
> I also expanded on the comments for the quotient-correction code a bit.

Nice. LGTM.
I've successfully tested the new patch again on both Intel and AMD.

I've marked it as Ready for Committer.

Regards,
Joel



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Optimize mul_var() for var1ndigits >= 8
Next
From: Andrei Lepikhov
Date:
Subject: Re: POC, WIP: OR-clause support for indexes