RFR 8017540: Improve multi-threaded contention behavior of BigInteger.toString() radix conversion cache (original) (raw)

Brian Burkhalter brian.burkhalter at oracle.com
Wed Jun 26 18:13:18 UTC 2013


So do we have consensus on this version?

Thanks for the lively "conversation."

Brian

On Jun 26, 2013, at 12:05 AM, Aleksey Shipilev wrote:

Yes, like that.

-Aleksey On 26.06.2013, at 10:53, Dmitry Nadezhin <dmitry.nadezhin at gmail.com> wrote:

We could check for the existing cacheLine.length right before installing the new one Do you mean something like this ? BigInteger getRadixConversionCache(int radix, int exponent) { BigInteger[] cacheLine = powerCache[radix]; // volatile read if (exponent < cacheLine.length)_ _return cacheLine[exponent];_ _int oldLength = cacheLine.length;_ _cacheLine = Arrays.copyOf(cacheLine, exponent + 1);_ _for (int i = oldLength; i < exponent + 1; i++)_ _cacheLine[i] = cacheLine[i - 1].square();_ _if (exponent >= powerCache[radix].length) { // volatile read again BigInteger[][] pc = Arrays.copyOf(powerCache); pc[radix] = cacheLine; powerCache = pc; // volatile write, publish } return cacheLine[exponent]; }



More information about the core-libs-dev mailing list