Re: Optimising numeric division - Mailing list pgsql-hackers

From Joel Jacobson
Subject Re: Optimising numeric division
Date
Msg-id 69e44b2e-fb47-4bdc-83fc-396bb6a270db@app.fastmail.com
Whole thread Raw
List pgsql-hackers
On Fri, Aug 23, 2024, at 21:21, Joel Jacobson wrote:
> On Fri, Aug 23, 2024, at 15:49, Dean Rasheed wrote:
>> The attached patch attempts to resolve those issues by replacing
>> div_var() and div_var_fast() with a single function intended to be
>> faster than both the originals.
...
> I've had an initial look at the code and it looks straight-forward,
> thanks to most of the complicated parts of the changed code is just
> change of NBASE to NBASE_SQR.

This part seems to be entirely new:

```
if (remainder[0] < 0)
{
    /* remainder < 0; quotient is too large */
    ...
}
else
{
    /* remainder >= 0 */
    ...
}
```

Maybe add some additional comments here? Or maybe it's fine already as is,
not sure what I think. Nothing specific here that is extra complicated,
but there are four nested branches, so quite a lot in total to keep track of.

Regards,
Joel



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: pg_verifybackup: TAR format backup verification
Next
From: Samuel Marks
Date:
Subject: [PATCH] Guard `CLOBBER_FREED_MEMORY` & `MEMORY_CONTEXT_CHECKING`