I present my feeble attempt to join the TM debate:
> TM introduces a variety of programming issues that
> are not present in lock-basedmutual exclusion.
> For example, semantics are muddled by:
> * Interaction with non-transactional codes,
> including access to shared data from outside
> of a transaction (tolerating weak atomicity)
> and the use of locks inside a transaction
> (breaking isolation to make locking operations
> visible outside transactions);
The referencing part is at least clearly defined: outside a
transaction, the refs are read-only.
Locking is a different beast. While true that it is a side-effect that
will creep to the outside world, I don't see how a lock inside a
transaction is bad in any way that a lock outside a transaction is
not. (But they might have yet to tell me since still not through with
the paper.)
> * Exceptions and serializability: how to handle
> exceptions and propagate consistent exception
> information from within a transactional context,
> and how to guarantee that transactional execution
> respects a correct ordering of operations;
A consistent snapshot of the world is presented inside a transaction.
Exceptions and serialization will be based on that world view.
I don't get what they mean by correct ordering of operations. Ordering
inside a transaction would matter just as much as it does in a
single-threaded scenario, would it not?
> * Interaction with code that cannot be
> transactionalized, due to either communication
> with other threads or a requirement barring
> speculation;
Just don't do that. Transactions are not a silver bullet. Use an agent instead.
> * Livelock, or the system guarantee that all
> transactions make progress even in the
> presence of conflicts.
True, TMs don't solve this for you. Just like locking doesn't solve
deadlocks for you.
A key assumption of the paper seems to be that TMs are the solution to
all things concurrency. But perhaps this is exactly the myth they are
trying to debunk?
My view is that TMs are another tool in the box, just like CAS, locks,
agents, volatile, thread-locals, immutables, atomics and all the rest
of java.util.concurrent. And I believe that people who think that
magical mechanism to solve all concurrency woes will drop in their
lap, are wrong and will (with high probability) be proven so
(hopefully before their systems go live).
--
Venlig hilsen / Kind regards,
Christian Vest Hansen.
On the other hand, interactions with non-TX code and livelock (p.41)
strike me as potential problems.
Bryan Cantrill concludes that "STM is a dog." That may be true, but I
am *sure* that locking is a bitch. :-)
Stuart
If Clojure's TM system tacks on a 20% overhead (note, I just made that
number up), that can pretty safely be ignored. The reason is that you
are only using TM for 20% of your concurrency support, if that. The
immutable data structures do the rest of the work for you with great
performance characteristics. Immutable data structures are the jack
hammer of Clojure's concurrency support. The STM is more like a
ball-peen hammer [1], taking care of the cases where shared state is,
indeed, necessary.
Regards,
- J.
[1] http://en.wikipedia.org/wiki/Ball-peen_hammer
the scary thing to me about the change from a world of possible
deadlock to a work of possible livelock is that the former is *really
easy to see* when it happens. :-)
I think this one comes down to the maturity of the implementations.
Deadlocks are only easy to see (in Java land) because we have tools
that make it so; ie. you can send SIGQUIT to the JVM and have all the
relevant information show up on stdout. Similarly, TMs could have some
sort of mechanism by which you could get a list of transactions with
high retry counts, and their most volatile (in the non-java-keyword
sense of the word) references.
Though I don't know much about TMs, I will grant that I have not
actually seen such tools for TMs, so your argument probably still
holds, but I don't think it will hold forever.
> Though I don't know much about TMs, I will grant that I have not
> actually seen such tools for TMs, so your argument probably still
> holds, but I don't think it will hold forever.
it is an interesting thing: the ecosystem of tools and things in the
crappy shared mutable state world is large and advanced, especially if
you have $$$ to throw at the problem (e.g. Azul's tools). which might
make it harder for the new idea to get fast and wide adoption. still,
one can hope that somehow the time + energy + resources somehow get
applied to making TM tools.
sincerely.
p.s. in java you can write a little thread which detects deadlock in
any other threads, so you can see it right away. we have such a thing
in our server code at the moment.
if you can share, i'd find it very interesting to learn about the top
5 or 10 such bugs.
sincerely.