Re: JavaMemoryModel: Re: Roach motel ordering: Do we have consensus?

From: Martin Trotter (martin_trotter@uk.ibm.com)
Date: Tue Jul 10 2001 - 10:30:06 EDT


Is performance really such an important characteristic of volatiles ? I
think it is probably more important
to ensure that someone using a volatile gets the sort of bahaviour they
would 'expect'. Given that volatile
has been so abused over the years it's really hard to say what that
expectation would be but my own
preference would be to err on the side of caution and define volatile with
two way barrier semantics.

The result would certainly be a perfomance degradation on some machines but
I've spent quite enough
time trying to unravel very strange timing issues in production code to
know that they are best avoided at
all costs ! Realistically the amount of code using volatiles is always
going to be very small and the effect
on total performance of any real application unlikely to be measurable.

Perhaps there's a case for 'strange' variables to give load.acquire and
st.release semantics ?

Martin Trotter

Java Development
IBM Centre for Java Technology

Bill Pugh <pugh@cs.umd.edu> on 07/08/2001 02:33:08 AM

Please respond to Bill Pugh <pugh@cs.umd.edu>

To: "Joseph Bowbeer" <jozart@csi.com>
cc: javamemorymodel@cs.umd.edu
Subject: Re: JavaMemoryModel: Re: Roach motel ordering: Do we have
      consensus?

At 5:39 PM -0700 7/7/01, Joseph Bowbeer wrote:
>Bill Pugh writes:
>
>> I would like to try to get this settled so we can move on to other
>> fun topics (like object initialization and final fields). David Holmes
>> expressed some reservations, but generally people seem to be
>> OK with "roach motel" ordering:
>
>I also have reservations about "roach motel" ordering.
>
>I'd rather err on the side of caution in this case. I'm also wondering
just
>how critical the performance of volatile is.

One of my major questions is: what applications/idioms need full
two-way memory barriers for volatiles. The only example I know of is
the simple version of Rob's optimistic reader's pattern, and that one
was so complicated and subtle it was deemed worthy of an ECOOP
publication. All of the other known uses of volatile just seem to
work correctly using the "roach motel" ordering.

If we know of a fair number of reasonable examples that required the
full memory barriers, I would be be more hesitant about "roach motel"
ordering.

So does anyone have any examples that require full memory barriers
for volatiles (besides the optimistic readers pattern)?

     Bill
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel

-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:33 EDT