Re: Refresh - Java 8 RFR 8017540: Improve multi-threaded contention behavior of BigInteger.toString() radix conversion cache

2013-07-01 Thread Aleksey Shipilev
On 06/28/2013 10:24 PM, Brian Burkhalter wrote: http://cr.openjdk.java.net/~bpb/8017540/ Thumbs up. -Aleksey. N.B.: You can put me in with Reviewed-by: shade.

Re: Refresh - Java 8 RFR 8017540: Improve multi-threaded contention behavior of BigInteger.toString() radix conversion cache

2013-07-01 Thread Alan Bateman
On 28/06/2013 19:24, Brian Burkhalter wrote: This Request for Review is a refresh of this thread http://mail.openjdk.java.net/pipermail/core-libs-dev/2013-June/018337.html pertaining to this issue http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8017540 The webrev has been updated in the

Re: Refresh - Java 8 RFR 8017540: Improve multi-threaded contention behavior of BigInteger.toString() radix conversion cache

2013-07-01 Thread Brian Burkhalter
On Jul 1, 2013, at 1:27 AM, Aleksey Shipilev wrote: On 06/28/2013 10:24 PM, Brian Burkhalter wrote: http://cr.openjdk.java.net/~bpb/8017540/ Thumbs up. Thanks. Now all we need is the imprimatur of an OpenJDK Reviewer. -Aleksey. N.B.: You can put me in with Reviewed-by: shade. Done.

Refresh - Java 8 RFR 8017540: Improve multi-threaded contention behavior of BigInteger.toString() radix conversion cache

2013-06-28 Thread Brian Burkhalter
This Request for Review is a refresh of this thread http://mail.openjdk.java.net/pipermail/core-libs-dev/2013-June/018337.html pertaining to this issue http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8017540 The webrev has been updated in the same location

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

2013-06-27 Thread Peter Levart
Hi, This version seems correct. Maybe just replace double volatile read at length re-check with a single one: private static BigInteger getRadixConversionCache(int radix, int exponent) { BigInteger[] cacheLine = powerCache[radix]; // volatile read if (exponent

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

2013-06-27 Thread Peter Levart
On 06/27/2013 08:37 AM, Peter Levart wrote: Hi, This version seems correct. Maybe just replace double volatile read at length re-check with a single one: private static BigInteger getRadixConversionCache(int radix, int exponent) { BigInteger[] cacheLine = powerCache[radix]; //

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

2013-06-27 Thread Peter Levart
Hi, Expanding on the idea of building single growing linked list of values and treating the array just as index for quick access which can be re-created at any time without synchronization or volatile publication, here's the attempt: private static class Node { final BigInteger

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

2013-06-27 Thread Peter Levart
Sorry for high frequency of messages. This one is even better. powerCacheIndex need not be holding Nodes, but BigIntegers instead. So no indirection on fast-path: private static class Node { final BigInteger value; Node next; Node(BigInteger value) { this.value =

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

2013-06-27 Thread Aleksey Shipilev
On 06/27/2013 10:37 AM, Peter Levart wrote: Hi, This version seems correct. Maybe just replace double volatile read at length re-check with a single one: private static BigInteger getRadixConversionCache(int radix, int exponent) { BigInteger[] cacheLine = powerCache[radix];

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

2013-06-27 Thread Brian Burkhalter
On Jun 27, 2013, at 4:18 AM, Aleksey Shipilev wrote: On 06/27/2013 10:37 AM, Peter Levart wrote: Hi, This version seems correct. Maybe just replace double volatile read at length re-check with a single one: private static BigInteger getRadixConversionCache(int radix, int exponent) {

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

2013-06-26 Thread Aleksey Shipilev
On 26.06.2013, at 7:31, Dmitry Nadezhin dmitry.nadez...@gmail.com wrote: We have two versions after private discussion with Aleksey. BigInteger getRadixConversionCache(int radix, int exponent) { BigInteger[][] pc = powerCache; // volatile read BigInteger[] cacheLine = pc[radix]; if

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

2013-06-26 Thread Dmitry Nadezhin
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

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

2013-06-26 Thread Aleksey Shipilev
Yes, like that. -Aleksey On 26.06.2013, at 10:53, Dmitry Nadezhin dmitry.nadez...@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) {

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

2013-06-26 Thread Brian Burkhalter
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.nadez...@gmail.com wrote: We could check for the existing cacheLine.length

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

2013-06-25 Thread Aleksey Shipilev
On 06/25/2013 03:53 AM, Brian Burkhalter wrote: http://cr.openjdk.java.net/~bpb/8017540/ Thanks! Looks good to me. Rather minor silly nit: cacheLine = Arrays.copyOf(cacheLine, exponent + 1); for (int i = oldSize; i = exponent; i++) { ...is probably more consistent as: cacheLine =

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

2013-06-25 Thread Alan Bateman
On 25/06/2013 00:53, Brian Burkhalter wrote: Branching off from this thread http://mail.openjdk.java.net/pipermail/core-libs-dev/2013-June/018244.html I filed this issue (should be public tomorrow) http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8017540 for the getRadixConversionCache()

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

2013-06-25 Thread Aleksey Shipilev
On 06/25/2013 08:29 PM, Brian Burkhalter wrote: Hi Aleksey, On Jun 25, 2013, at 1:40 AM, Aleksey Shipilev wrote: Thanks! Looks good to me. Cool! Hold on now. Similar to what Peter suggests in the separate thread, there is the data race between 3458 and 3466: 3455 private static

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

2013-06-25 Thread Dmitry Nadezhin
What about such code ? BigInteger getRadixConversionCache(int radix, int exponent) { BigInteger retVal = null; BigInteger[][] pc = powerCache; // volatile read BigInteger[] cacheLine = pc[radix]; int oldSize = cacheLine.length; if (exponent = oldSize) { cacheLine =

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

2013-06-25 Thread Peter Levart
On 06/25/2013 09:12 PM, Aleksey Shipilev wrote: It might be a good idea to turn $powerCache final, not volatile, since the code will recover anyway. The trouble I'm seeing is weak enough hardware, which will never see the updated value of cacheLine, always falling back. Hence, I'm keen to keep

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

2013-06-25 Thread Aleksey Shipilev
On 06/25/2013 11:36 PM, Dmitry Nadezhin wrote: What about such code ? BigInteger getRadixConversionCache(int radix, int exponent) { BigInteger retVal = null; BigInteger[][] pc = powerCache; // volatile read BigInteger[] cacheLine = pc[radix]; int oldSize = cacheLine.length; if

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

2013-06-25 Thread Peter Levart
On 06/25/2013 09:50 PM, Aleksey Shipilev wrote: On 06/25/2013 11:38 PM, Peter Levart wrote: On 06/25/2013 09:12 PM, Aleksey Shipilev wrote: It might be a good idea to turn $powerCache final, not volatile, since the code will recover anyway. The trouble I'm seeing is weak enough hardware,

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

2013-06-25 Thread Aleksey Shipilev
On 06/26/2013 12:34 AM, Peter Levart wrote: On 06/25/2013 09:50 PM, Aleksey Shipilev wrote: On 06/25/2013 11:38 PM, Peter Levart wrote: On 06/25/2013 09:12 PM, Aleksey Shipilev wrote: It might be a good idea to turn $powerCache final, not volatile, since the code will recover anyway. The

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

2013-06-25 Thread Peter Levart
On 06/25/2013 10:34 PM, Peter Levart wrote: On 06/25/2013 09:50 PM, Aleksey Shipilev wrote: On 06/25/2013 11:38 PM, Peter Levart wrote: On 06/25/2013 09:12 PM, Aleksey Shipilev wrote: It might be a good idea to turn $powerCache final, not volatile, since the code will recover anyway. The

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

2013-06-25 Thread Aleksey Shipilev
On 06/26/2013 12:56 AM, Peter Levart wrote: Sorry, you are storing back when resizing. And you are resizing for every exponent that is bigger that previous requested (cached). This can lead to many resizings. Dmitry had suggested going back to square one with his approach. I'll let him post

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

2013-06-25 Thread Steven Schlansker
On Jun 25, 2013, at 1:56 PM, Peter Levart peter.lev...@gmail.com wrote: Sorry, you are storing back when resizing. And you are resizing for every exponent that is bigger that previous requested (cached). This can lead to many resizings. Hi everyone, Apologies to butt in, and maybe this

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

2013-06-25 Thread Dmitry Nadezhin
We have two versions after private discussion with Aleksey. BigInteger getRadixConversionCache(int radix, int exponent) { BigInteger[][] pc = powerCache; // volatile read BigInteger[] cacheLine = pc[radix]; if (exponent cacheLine.length) return cacheLine[exponent]; int oldSize =

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

2013-06-24 Thread Brian Burkhalter
Branching off from this thread http://mail.openjdk.java.net/pipermail/core-libs-dev/2013-June/018244.html I filed this issue (should be public tomorrow) http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8017540 for the getRadixConversionCache() enhancement. The patch is here