"Even though the program textually looks like I read that variable over and over again, in practice I don't. I'm going to read it once and I'm going to leave it in the register and I'm going to do all of my modifications and work on it in the register computing the same value I would as if I'd written it down to memory and then loaded it back up into memory."The discussion touched on a number of points about the under-pinnings of Java and features that the execution stack must have in order to support true multi-threaded applications. Cliff explains how the different hardware memory models work to protect us against discovering data race bugs in our applications. He provides an in depth analysis of double check locking. The talk winds down with a small discussion of things that Cliff believes would be helpful in our future efforts to produce bug free multi-threaded code. Download the podcast and read the full interview transcript here
-
Podcast - Cliff Click on the Java memory model, multi-threading (18 messages)
- Posted by: Nitin Bharti
- Posted on: July 25 2007 12:54 EDT
While at TSSJS Barcelona, Cliff Click from Azul systems spoke with Kirk Pepperdine about his work at Azul, his involvement with the -server compiler team, and a whole host of hardware issues as they relate to the Java memory model, thread safety, and program correctness. When asked what it meant for the compiler to "hoist" a variable, Cliff responded with an in depth explanation of the technique as well as its implications on correctness.Threaded Messages (18)
- Re: Podcast - Cliff Click on the Java memory model, multi-thread by Cameron Purdy on July 25 2007 15:53 EDT
- Re: Podcast - Cliff Click on the Java memory model, multi-thread by William Louth on July 26 2007 10:45 EDT
- Re: Podcast - Cliff Click on the Java memory model, multi-thread by Talip Ozturk on July 26 2007 04:19 EDT
- great talk by peter lin on July 26 2007 08:55 EDT
- Re: great talk by Rex Guildo on July 26 2007 12:11 EDT
- Re: great talk by Kirk Pepperdine on July 26 2007 14:22 EDT
-
Re: great talk by Rex Guildo on July 26 2007 06:29 EDT
-
Re: great talk by John Brand on July 27 2007 04:25 EDT
-
Re: great talk by Rex Guildo on July 27 2007 04:57 EDT
-
Re: great talk by John Brand on July 27 2007 05:26 EDT
-
Re: great talk by Rex Guildo on July 27 2007 05:40 EDT
-
Re: great talk by John Brand on July 27 2007 06:44 EDT
- Re: great talk by Rex Guildo on July 27 2007 06:59 EDT
-
Re: great talk by Anthony Jayasekera on July 27 2007 12:01 EDT
- Re: great talk by Rex Guildo on July 28 2007 04:27 EDT
- statics by Cameron Purdy on July 29 2007 11:13 EDT
-
Re: great talk by John Brand on July 27 2007 06:44 EDT
- Re: great talk by rory Winston on July 28 2007 12:18 EDT
-
Re: great talk by Rex Guildo on July 27 2007 05:40 EDT
-
Re: great talk by John Brand on July 27 2007 05:26 EDT
-
Re: great talk by Rex Guildo on July 27 2007 04:57 EDT
-
Re: great talk by John Brand on July 27 2007 04:25 EDT
- Re: great talk by peter lin on July 26 2007 10:01 EDT
-
Re: great talk by Rex Guildo on July 26 2007 06:29 EDT
-
Re: Podcast - Cliff Click on the Java memory model, multi-thread[ Go to top ]
- Posted by: Cameron Purdy
- Posted on: July 25 2007 15:53 EDT
- in response to Nitin Bharti
Cliff is one of the brightest engineers I have had the pleasure of meeting and working with .. beyond doubt, when it comes to software and technology, he is worth listening to. Peace, Cameron Purdy Oracle Coherence: The Java Data Grid -
Re: Podcast - Cliff Click on the Java memory model, multi-thread[ Go to top ]
- Posted by: William Louth
- Posted on: July 26 2007 10:45 EDT
- in response to Cameron Purdy
As well as being very bright he is also extremely amiable - especially when discussing contentious performance observations and/or opinions. Cliff was more than willing to share his time when he could have easily followed the example of others and lazily rebuffed an observation without first attempting to understand the wider context. I was pleasantly surprised with the level of attention he afforded questions we made. This is a very good interview with Kirk that contains much more information than one expects. regards, William -
Re: Podcast - Cliff Click on the Java memory model, multi-thread[ Go to top ]
- Posted by: Talip Ozturk
- Posted on: July 26 2007 04:19 EDT
- in response to Nitin Bharti
Here is the link for Cliff's talk at Google Tech Talks on Lock-Free Hash Table. http://video.google.com/videoplay?docid=2139967204534450862 He is simply amazing... -
great talk[ Go to top ]
- Posted by: peter lin
- Posted on: July 26 2007 08:55 EDT
- in response to Nitin Bharti
Listened to it yesterday and it was excellent. Too bad a lot of it is over my head. -
Re: great talk[ Go to top ]
- Posted by: Rex Guildo
- Posted on: July 26 2007 12:11 EDT
- in response to peter lin
Listened to it yesterday and it was excellent. Too bad a lot of it is over my head.
+1 Here is some additional Java Memory Model stuff: http://gee.cs.oswego.edu/dl/jmm/cookbook.html -
Re: great talk[ Go to top ]
- Posted by: Kirk Pepperdine
- Posted on: July 26 2007 14:22 EDT
- in response to peter lin
Listened to it yesterday and it was excellent. Too bad a lot of it is over my head.
I'd appreciate knowing where things got a bit steep. Kind regards, Kirk -
Re: great talk[ Go to top ]
- Posted by: Rex Guildo
- Posted on: July 26 2007 18:29 EDT
- in response to Kirk Pepperdine
For me, this was not easiest part: "Cliff Click: Yeah. So, atomics are another, are, well, atomics are Java’s way of getting at the CAS instruction, which is, stands for Compare-And-Swap, it’s the unit atomic update on all modern platforms. PowerPC does something called load-link-store-conditional, it’s very similar, the differences are very minor, but basically it means that you can do a read-modify-write cycle atomically. And that’s the key bit that we will build all of the synchronization primitives out , not just the synchronized keyword, VMs have internal locking that’s built on top of these but also the java.util.concurrent utilities have you know the Doug Lea Lock – capital L – Lock structures, the re-enterant Lock, the read-and-write-Lock, and all those locks are all built on CAS instructions as well. So, under the hood, they use the CAS instruction. And that’s what atomic is, it gives you direct access to CAS instruction." Anybody out there uses volatile to fix the double checked locking?Listened to it yesterday and it was excellent. Too bad a lot of it is over my head.
I'd appreciate knowing where things got a bit steep. -
Re: great talk[ Go to top ]
- Posted by: John Brand
- Posted on: July 27 2007 04:25 EDT
- in response to Rex Guildo
Anybody out there uses volatile to fix the double checked locking?
There is a better way, which works in JVMs before the new memory model as well, - Pughs singleton holder. -
Re: great talk[ Go to top ]
- Posted by: Rex Guildo
- Posted on: July 27 2007 04:57 EDT
- in response to John Brand
Any references?Anybody out there uses volatile to fix the double checked locking?
There is a better way, which works in JVMs before the new memory model as well, - Pughs singleton holder. -
Re: great talk[ Go to top ]
- Posted by: John Brand
- Posted on: July 27 2007 05:26 EDT
- in response to Rex Guildo
For instance http://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html search for "Initialization On Demand Holder". Some more explanation (Goetz): http://www-128.ibm.com/developerworks/java/library/j-jtp03304/.
Any references?Anybody out there uses volatile to fix the double checked locking?
There is a better way, which works in JVMs before the new memory model as well, - Pughs singleton holder. -
Re: great talk[ Go to top ]
- Posted by: Rex Guildo
- Posted on: July 27 2007 05:40 EDT
- in response to John Brand
For instance http://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html search for "Initialization On Demand Holder".
Thanks. Static initializer would be an easier name. Which pattern is used by Spring to create Singletons? -
Re: great talk[ Go to top ]
- Posted by: John Brand
- Posted on: July 27 2007 06:44 EDT
- in response to Rex Guildo
Static inializer would be too general. The neat trick with the holder is that it defers creation of the singleton instance untill someone calls "getInstance". If the instance is just created in a static initializer then it would be created when the singleton class is loaded.For instance http://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html search for "Initialization On Demand Holder".
Thanks. Static initializer would be an easier name.
Which pattern is used by Spring to create Singletons? -
Re: great talk[ Go to top ]
- Posted by: Rex Guildo
- Posted on: July 27 2007 06:59 EDT
- in response to John Brand
Yor are right.For instance http://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html search for "Initialization On Demand Holder".
Thanks. Static initializer would be an easier name.
Which pattern is used by Spring to create Singletons?
Static inializer would be too general.
The neat trick with the holder is that it defers creation of the singleton instance untill someone calls "getInstance". If the instance is just created in a static initializer then it would be created when the singleton class is loaded. -
Re: great talk[ Go to top ]
- Posted by: Anthony Jayasekera
- Posted on: July 27 2007 12:01 EDT
- in response to John Brand
Aren't the two following code snippets exactly equivelent in terms of when the instantiation of Something occurs? public static Something something = new Something(); public static Something something; static{ something = new Something(); } My understanding is that for both the instantiation will occur the first time any kind of reference is made to the class containing these static declarations e.g. Class.forName("ContainingClass"). Is this not correct? -
Re: great talk[ Go to top ]
- Posted by: Rex Guildo
- Posted on: July 28 2007 04:27 EDT
- in response to Anthony Jayasekera
{...} Is this not correct?
Check this:private static class LazySomethingHolder { public static Something something = new Something(); }public static Something getInstance() { return LazySomethingHolder.something; } -
statics[ Go to top ]
- Posted by: Cameron Purdy
- Posted on: July 29 2007 23:13 EDT
- in response to Anthony Jayasekera
Aren't the two following code snippets exactly equivelent in terms of when the instantiation of Something occurs?
Yes, those two are identical. Peace, Cameron Purdy Oracle Coherence: The Java Data Grid
public static Something something = new Something();
public static Something something;
static{
something = new Something();
} -
Re: great talk[ Go to top ]
- Posted by: rory Winston
- Posted on: July 28 2007 12:18 EDT
- in response to John Brand
Was it Pugh that invented this idiom? I thought it was Lea - at least, it's in his (now very old) Concurrent Programming in Java, first edition. Anyways, I've only seen the Lock-Free Hashtable talk by Clif Click on Google, but I was very, very impressed. Particularly at his thoughtful answers to questions.
Any references?Anybody out there uses volatile to fix the double checked locking?
There is a better way, which works in JVMs before the new memory model as well, - Pughs singleton holder.
For instance http://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html search for "Initialization On Demand Holder".
Some more explanation (Goetz): http://www-128.ibm.com/developerworks/java/library/j-jtp03304/. -
Re: great talk[ Go to top ]
- Posted by: peter lin
- Posted on: July 26 2007 22:01 EDT
- in response to Kirk Pepperdine
The locking bits was a bit hard for me to get, but that's my own limitation. The explanations were good, I just lack the depth to really understand the subtleties and know where and how locking becomes difficult. peterListened to it yesterday and it was excellent. Too bad a lot of it is over my head.
I'd appreciate knowing where things got a bit steep. Kind regards,
Kirk