RFR 8246050: Improve scalability of MemoryScope
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Thu May 28 11:20:14 UTC 2020
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