Fork me on GitHub

Sunday, June 27, 2010

Introducing Multiverse Software Transactional Memory for JRuby

I haven't written for quite sometime. I have been busy working on one of areas I really love, Concurrency. People who have followed me for sometime in twitter or heard my talk in Rubyconf about Concurrency Paradigms with Hari would have understood this. Recently I have been exploring alternate forms of concurrency other than the normal locks, mutex and conditional variable ones.

I love the message passing concurrency for its simplicity in removing the concept of shared memory (Still doesn't mean we will not have state dependence :). But there are at times when we need shared state and safe access to it. This problem of strategy for accessing a shared state among multiple threads of execution has been already solved in database world. Transactions gives a really good answer for this. Currently I am working on using Multiverse STM in JRuby (As earlier I had used Clojure). This time it is a complete Software Transactional Memory with support for atomic (transactional), retry (blocking) and orElse (choice) primitives. Multiverse is the transactional Memory on JVM and is the one behind Akka's STM. It uses TL2 algorithms (which has global version clock and commit time locking) as well as flexible to accommodate other algorithms.

Check out the code in multiverse git repo git:// There is a nice implementation of Dijkstra's Dining Philosopher's problem in it using atomic and retry...

Let me know your thoughts. Look out for more posts on the internals of the STM :)