From: cliffc <cli...@acm.org>
Date: Tue, 27 May 2008 09:17:09 -0700 (PDT)
Local: Tues, May 27 2008 12:17 pm
Subject: Re: STM criticism from Azul Systems
On May 25, 9:31 am, Phil Jordan <li...@philjordan.eu> wrote:
> I'm new to STM, I've stumbled into it after doing some
Let's see if I can do you some justice...
> explicit/low-level lock-free programming and systems that are > synchronised classically with mutex/semaphore-based locking. I > especially don't know what goes on under the hood in Clojure's STM > implementation, or how powerful the JVM is in terms of memory guarantees. > I'm chipping in out of interest and to improve my understanding,
> From personal experience, this is far from the truth in complex
Yup. So the deadlock happened. Ouch.
> systems. Deadlocks happening only on "in the wild" systems, appearing in > the form of heisenbugs, etc. Not fun at all. There's too much in the way > of implicit contracts going on, which blows up in your face if you're > trying to extend undocumented software that was written by someone who > left the company before you arrived. > (and we all know the "well then document it" approach just doesn't happen in practice)
Yup, but You could make a difference. HotSpot probably has the
highest level of 'asserts' per line of code (and a pretty darned high level of comments per line of code) of anything Out There. Docs are cheaper than debugging. But it's an aside.... back to deadlocks-in- practice: > Maybe it's just the implementations I've used (pthreads, Win32, OpenMP) and others give you higher-level diagnostics, but at the level I was
Crash dump? Core file? 'ctrl-backslash' to a JVM to get a thread-
> working it could get very painful. > > You get a crash dump, crawl the stacks, discover the lock cycle & reorganize.
> You need a reasonable amount of infrastructure in place for that,
dump? This stuff is commonly available. If you don't have a proper tool chain, then Job One for you should be to go get one - and I'm very serious here. Drop everything else until you get a functional 'path' (protocol, implementation, business process, etc) that allows you do debug a crash from a customer in the field. You might need a willing beta-partner for this, hand him a broken program & let it crash, figure out he needs disk-space to capture the core & logs, needs training to hit 'ctrl-backslash' when suspecting a deadlock, etc - plus FTP the files back to Home Base, plus you need to be able to capture the files per-customer-per-bug (ala Bugzilla), then decrypt the file (gdb for core, eyeballs or a little perl for stack-trace logs), etc, etc, etc, .... No Rocket Science, but annoying bits of Engineering along with some Customer Management. > plus you're relying on absence of evidence rather than proof that it can't deadlock.
Err.... No.
I'm not shooting for perfection here; I'm shooting for "good enough to
> > Dev's don't like 'em, but they don't lose sleep over them either.
> The people who lose sleep over software quality are probably the kind who try to avoid complex locking schemes like the plague in the first place. :)
thinking about the problem ahead of time they are going to be way way ahead in the long run. > My understanding is that this is exactly the kind of situation where STM
Sigh - we mentally missed here.
> excels: you wrap the two add calls in a transaction rather than making > them individually atomic. The way Clojure handles this (I've been > spending 99.9% of my time in Clojure on non-threaded things, so I could > easily have missed something) is that your _money would be a ref, and > any attempt at modifying it will fail unless you're in a transaction. > Wrapping the 'add' around the transaction would be the anti-pattern > here, you want to make the 'transfer' a transaction. > Okay, you kind of lost me with what you're trying to say here. Trivial examples are.... trivial. They can be fixed in a thousand
...I might have avoided some potential deadlocks (HotSpot uses lock
Instead of deadlock, HS crashes far far more often because the locks
Here's where I want some kind of compiler support. 'Ref' helps -
> ~phil
Cliff
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||