Re: [PATCH] Use 128-bit math to accelerate numeric division, when 8 < divisor digits <= 16 - Mailing list pgsql-hackers

From Dean Rasheed
Subject Re: [PATCH] Use 128-bit math to accelerate numeric division, when 8 < divisor digits <= 16
Date
Msg-id CAEZATCV4sC7-pMDi3JV3rT9HVHjvJtAku_CaX0Jxk1HvDgCLxw@mail.gmail.com
Whole thread Raw
In response to [PATCH] Use 128-bit math to accelerate numeric division, when 8 < divisor digits <= 16  ("Joel Jacobson" <joel@compiler.org>)
Responses Re: [PATCH] Use 128-bit math to accelerate numeric division, when 8 < divisor digits <= 16
List pgsql-hackers
On Sun, 22 Jan 2023 at 13:42, Joel Jacobson <joel@compiler.org> wrote:
>
> Hi,
>
> On platforms where we support 128bit integers, we could accelerate division
> when the number of digits in the divisor is larger than 8 and less than or
> equal to 16 digits, i.e. when the divisor that fits in a 64-bit integer but would
> not fit in a 32-bit integer.
>

Seems like a reasonable idea, with some pretty decent gains.

Note, however, that for a divisor having fewer than 5 or 6 digits,
it's now significantly slower because it's forced to go through
div_var_int64() instead of div_var_int() for all small divisors. So
the var2ndigits <= 2 case needs to come first.

The implementation of div_var_int64() should be in an #ifdef HAVE_INT128 block.

In div_var_int64(), s/ULONG_MAX/PG_UINT64_MAX/

Regards,
Dean



pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: run pgindent on a regular basis / scripted manner
Next
From: Himanshu Upadhyaya
Date:
Subject: Re: HOT chain validation in verify_heapam()