Re: Optimize mul_var() for var1ndigits >= 8

Joel Jacobson <joel@compiler.org>

From: "Joel Jacobson" <joel@compiler.org>
To: "Dean Rasheed" <dean.a.rasheed@gmail.com>
Cc: "Tom Lane" <tgl@sss.pgh.pa.us>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2024-08-14T06:30:55Z
Lists: pgsql-hackers

Attachments

On Tue, Aug 13, 2024, at 13:01, Joel Jacobson wrote:
> I think this is acceptable, since it produces more correct results.

In addition, I've traced the rscale_adjustment -15 mul_var() calls to originate
from numeric_exp() and numeric_power(), so I thought it would be good to
brute-force test those as well, to get an idea of the probability of different
results from those functions.

Brute-force testing of course doesn't prove it's impossible to happen,
but millions of inputs didn't cause any observable differences in the
returned results, so I think it's at least very improbable to
happen in practice.

Regards,
Joel

Commits

  1. Optimise numeric multiplication using base-NBASE^2 arithmetic.

  2. Extend mul_var_short() to 5 and 6-digit inputs.