Re: Optimising numeric division

From: "Joel Jacobson" <joel(at)compiler(dot)org>
To: "Dean Rasheed" <dean(dot)a(dot)rasheed(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Optimising numeric division
Date: 2024-08-23 21:03:56
Message-ID: 69e44b2e-fb47-4bdc-83fc-396bb6a270db@app.fastmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Samuel Marks 2024-08-23 21:09:22 [PATCH] Guard `CLOBBER_FREED_MEMORY` & `MEMORY_CONTEXT_CHECKING`
Previous Message Jeff Davis 2024-08-23 20:49:52 Re: Statistics Import and Export