RFR 8246050: Improve scalability of MemoryScope
Paul Sandoz
paul.sandoz at oracle.com
Thu May 28 17:56:33 UTC 2020
+1 (previously reviewed on the panama-dev list)
It’s very pleasing to see this get simplified through some good collaboration. StampedLock is quite powerful, and likely an under utilized resource.
Paul.
> On May 28, 2020, at 4:20 AM, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
>
> Hi,
> during the review of [1] it emerged that the implementation of the memory scope abstraction (which is used to keep track of temporal scope of a memory segment) does not scale well in situations where there is a lot of contention on the acquire() method due to many threads working simultaneously on different chunks of the segment.
>
> Peter has proposed an alternate implementation [2] which, instead of using CAS, it cleverly uses LongAdders.
>
> While that implementation worked correctly, we managed to simplify it further, by realizing that what we needed here was an instance of a read-write lock: a thread that acquires a segment does a "read", while a thread closing a segment does a "write". By using optimistic reads with a StampedLock we were able to gain back scalability and maintain the code relatively readable.
>
> Webrev:
>
> http://cr.openjdk.java.net/~mcimadamore/8246050/webrev/
>
> Cheers
> Maurizio
>
> [1] - https://mail.openjdk.java.net/pipermail/core-libs-dev/2020-April/066136.html
> [2] - https://git.openjdk.java.net/panama-foreign/pull/142
>
More information about the core-libs-dev
mailing list