[concurrency-interest] The very best CAS loop
aph at redhat.com
Thu Sep 29 04:32:51 EDT 2016
On 28/09/16 21:02, Paul Sandoz wrote:
> 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.
Right, I get that. So this is a slightly artificial case: if we'd been
doing a few thousand accesses to the same buffer we'd perhaps see
something which better represents real-life Java.
More information about the Concurrency-interest