[concurrency-interest] The very best CAS loop

Paul Sandoz paul.sandoz at oracle.com
Wed Sep 28 16:02:40 EDT 2016


> On 28 Sep 2016, at 06:08, Andrew Haley <aph at redhat.com> wrote:
> 
> I did a few experiments, with simpler code.
> 
> The version with the direct byte buffer was not very efficient: it
> does many reads of memory unrelated to the actual thing we're trying
> to test.  This is a shame, given that one of the goals of JEP 193 is
> that the API should be at least as good as Unsafe.  Right now we'e a
> long way from that goal.
> 

Alas, it’s tricky to do better while retaining safe access, there are:

- bounds checks;
- read only checks;
- alignment checks; and
- that the buffer is effectively a box of the address (base & offset, where base == null for off-heap).

When looping the checks can be hoisted, and unrolling should result in efficient addressing. So, e.g. for plain access, a the generated hot-loop is similar to that as if Unsafe was directly used.

Project Panama is likely to run into similar challenges with it’s Pointer and (Bounded)MemoryRegion.

Paul.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20160928/e9c88a67/attachment-0001.sig>


More information about the Concurrency-interest mailing list