JavaMemoryModel: Cost of marking things volatile

From: Bill Pugh (pugh@cs.umd.edu)
Date: Tue Nov 09 1999 - 12:22:27 EST


I changes all of the non-final fields in the JDK and in the spec
benchmarks to be volatile.

For the exact VM, I got the following results for the volatile version:
SPEC ratios thus far, slowest / fastest
_227_mtrt 26.2 26.2
_202_jess 18.0 18.0
_201_compress 22.5 22.5
_209_db 7.38 7.38
_222_mpegaudio 20.8 20.8
_228_jack 15.6 15.6
_213_javac 9.82 9.82
Geometric Mean 15.8 15.8

without marking things volatile, I got:

SPEC ratios thus far, slowest / fastest
_227_mtrt 25.2 25.2
_202_jess 17.6 17.6
_201_compress 24.8 24.8
_209_db 7.48 7.48
_222_mpegaudio 20.4 20.4
_228_jack 16.8 16.8
_213_javac 9.93 9.93
Geometric Mean 16.1 16.1

So here, there isn't much cost for marking things volatile.

I tried it with HotSpot and got zero cost for marking things
volatile. On further checking, I found that HotSpot was doing
reorderings that were not legal for volatile variables. I checked
with Cliff Click and he confirmed that at the moment, HotSpot ignores
the volatile flag (he has made fixing this a priority item).

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



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