On 05/30/2016 07:47 PM, Aleksey Shipilev wrote:
On 05/30/2016 06:59 PM, Peter Levart wrote:
I also employed get-acquire/put-release memory ordering semantics
instead of SC (volatile) in hope that it might improve a bit the
performance on platforms such as PowerPC or ARM, but this can be changed
back to SC if anyone gets scared of it :-)
Revert, you're playing with fire here. Your _default_ modus operandi
should be "scared" when dealing with concurrency. The correctness with
acq/rel should be proven separately, and not by empirical testing. There
is a reason why putOrdered is not used everywhere.

Thanks,
-Aleksey

Hi Aleksey,

You are right. Users kind of expect from a general construct like ConcurrentMap to behave in a SC manner. Although my use of get-acquire/put-release in a Map-like construct could be correct by itself, it might be surprising for users to observe things like:

final static LinearProbeHashtable<Integer, Integer> t = new LinearProbeHashtable<>();

Thread A:
t.put(1, 10);

Thread B:
t.put(2, t.get(1));

Thread C:
Integer v2 = t.get(2);
Integer v1 = t.get(1);

with a possible outcome of (v1, v2) being (null, 10);

Will revert that to volatile semantics...

Regards, Peter




_______________________________________________
mlvm-dev mailing list
mlvm-dev@openjdk.java.net
http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev

_______________________________________________
mlvm-dev mailing list
mlvm-dev@openjdk.java.net
http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev

Reply via email to