JDK 8 RFC 4891331: BigInteger a.multiply(a) should use squaring code

Joseph Darcy joe.darcy at oracle.com
Thu Oct 17 23:08:21 UTC 2013


Hi Brian,

On 10/17/2013 12:26 PM, Brian Burkhalter wrote:
> This post concerns this issue:
>
> https://bugs.openjdk.java.net/browse/JDK-4891331
>
> I performed some tests using JMH [1] on Mac OS X [2] and Windows 7 [3]. The tests were equivalent to calling multiply() with argument == this for bit lengths from 32 through 448 without and with this patch applied:
>
> --- a/src/share/classes/java/math/BigInteger.java	Thu Oct 17 11:34:01 2013 -0400
> +++ b/src/share/classes/java/math/BigInteger.java	Thu Oct 17 11:45:42 2013 -0700
> @@ -1374,6 +1374,10 @@
>           if (val.signum == 0 || signum == 0)
>               return ZERO;
>   
> +        if (val == this) {
> +            return square();
> +        }
> +
>           int xlen = mag.length;
>           int ylen = val.mag.length;
>
> A table of the ratios of throughput with the patch applied to throughput without the patch applied is here:
>

Can you test the performance of a patch with:

     if (val == this and mag.length > 8)

Do you have any measurements of the multiply performance of values that 
are not ==? (Making sure there is no general regression.)

Thanks,

-Joe



More information about the core-libs-dev mailing list