Re: STM and useful concurrency

2009-03-25 Thread cliffc
A bunch of separate real concerns here: --- On the issue of STM Slowdown: - Clojure is typically slower than Java by an interesting amount when doing Plain Olde Java Stuff, unless great care is taken (it's possible to take great care). Such a slowdown matters less than the ability t

Re: STM and useful concurrency

2009-03-24 Thread Christian Vest Hansen
On Tue, Mar 24, 2009 at 11:40 PM, Howard Lewis Ship wrote: > > A relevant question is: what is the relative cost of locking and > blocking (in the pure Java approach) vs. the cost of retrying (in the > Clojure/STM approach). I can't think, off the top of my head, of a fair way to compare the two

Re: STM and useful concurrency

2009-03-24 Thread Dan
> > I don't want to go out on a limb, having not looked at the Clojure STM > implementation. However, I would bet that the costs are roughly equal. > Even if Clojure was 50% slower, or 100% slower, the knowlege that you > can spin up a large number of threads and not worry about deadlocks is > ulti

Re: STM and useful concurrency

2009-03-24 Thread Howard Lewis Ship
A relevant question is: what is the relative cost of locking and blocking (in the pure Java approach) vs. the cost of retrying (in the Clojure/STM approach). I don't want to go out on a limb, having not looked at the Clojure STM implementation. However, I would bet that the costs are roughly equa

Re: STM and useful concurrency

2009-03-24 Thread Tom Davies
I think Cliff may mean that each STM-participating memory access is 3x slower, but in Clojure, because of immutability, a very small proportion of accesses are Ref accesses, whereas in C/C++ *all* memory accesses would be. I agree that there's lots of room for adding instrumentation to Clojure's

Re: STM and useful concurrency

2009-03-24 Thread Bradbev
On Mar 24, 5:56 am, cliffc wrote: > Some generic STM bits of wisdom: > > - STMs in "standard" languages (e.g. C, C++) suffer from having to > track all memory references.  THis overhead means the STM code > typically starts 3x to 10x slower than non-STM code, which is a pretty > stiff penalty t

Re: STM and useful concurrency

2009-03-24 Thread cliffc
Some generic STM bits of wisdom: - STMs in "standard" languages (e.g. C, C++) suffer from having to track all memory references. THis overhead means the STM code typically starts 3x to 10x slower than non-STM code, which is a pretty stiff penalty to recover from. If you're only getting a 3x spe

Re: STM and useful concurrency

2009-03-24 Thread Mark Volkmann
As was described in a "Software Engineering Radio" podcast on transactional memory, there are many parallels between garbage collection and transactional memory. Some parallels that aren't in place yet though include: 1) There are tools to measure the impact of GC on runs of an application, but w

Re: STM and useful concurrency

2009-03-23 Thread Luc Prefontaine
On Mon, 2009-03-23 at 14:49 -0500, Cosmin Stejerean wrote: > > > The fact that B is tried once concurrently with A, and is then aborted > and retried is in my opinion the same as transaction B being stuck > waiting on a lock while A is being processed, but I can see how trying > B concurrently

Re: STM and useful concurrency

2009-03-23 Thread Cosmin Stejerean
On Mon, Mar 23, 2009 at 2:36 PM, Mark Volkmann wrote: > > > In the case where two transactions need to modify the same Ref they > > definitely to be serialized, either by explicitly using locks in Java, or > by > > letting Clojure automatically retry one of them. In either case it about > the > >

Re: STM and useful concurrency

2009-03-23 Thread Raoul Duke
> that was happening? I know I could insert my own code to track that, > but it seems like this may be a commonly needed tool for Clojure to > detect excessive conflicts/retries in transactions. Maybe we could set > a special variable like *track-retries* that would cause Clojure to > produce a te

Re: STM and useful concurrency

2009-03-23 Thread Mark Volkmann
On Mon, Mar 23, 2009 at 11:19 AM, Cosmin Stejerean wrote: > > On Sun, Mar 22, 2009 at 9:12 PM, Mark Volkmann > wrote: >> >> I'm trying to understand the degree to which Clojure's STM provides >> more concurrency than Java's blocking approach. I know it's difficult >> to make generalizations and

Re: STM and useful concurrency

2009-03-23 Thread Cosmin Stejerean
On Sun, Mar 22, 2009 at 9:12 PM, Mark Volkmann wrote: > > I'm trying to understand the degree to which Clojure's STM provides > more concurrency than Java's blocking approach. I know it's difficult > to make generalizations and that specific applications need to be > measured, but I'll give it a g

Re: STM and useful concurrency

2009-03-22 Thread e
i think it would be awesome if someone worked up a scenario . . . started using regular old java . . . and we could walk into a few gotchas, publicly/transparently, where a serious java guy could chime in ... and really see what the stm buys. Then we'd have an even richer appreciation for the STM

STM and useful concurrency

2009-03-22 Thread Mark Volkmann
I'm trying to understand the degree to which Clojure's STM provides more concurrency than Java's blocking approach. I know it's difficult to make generalizations and that specific applications need to be measured, but I'll give it a go anyway. Clearly using STM (dosync with Refs) makes code easie