Transactional Memory, a distant dream?

28 03 2009

Have you ever felt the necessity for writing code which looks something like this?

atomic {
obj = msgNotProcessedMap.get(key);
obj.setProcessedTimestamp(timestamp);
msgProcessedMap.put(key,obj);
msgNotProcessedMap.remove(obj);
}

Well, I have been following the evolution of both software transactional memory as well as hardware support for it. Back in 2006, when I first started my in-depth look at this new emerging area, I felt that there was a lot of promise and expected it to go mainstream pretty quick, but here we are, in 2009 now, and I have become a bit skeptical.

There is still a lot of ongoing research in this area and there are a few STM implementations available out there, but they are not really mainstream. As skeptical as I am, I still see some hope for it to be part of Java 8.0 or C# 4.0, yes, nothing short of native language support.

Sun Microsystems has come up with their Hybrid Transactional Memory (HyTM), which uses STM as much as possible and exploits the underlying hardware when it comes to optimistic concurrency control. Sun has confirmed it’s on track to ship its “Supernova” servers based on its “Rock” UltraSparc-RK processors before the end of 2009, so let us wait and see.

Without native language support, the effort that a programmer has to incur would be significant and in a way more error prone than what they are accustomed to currently (synchronized constructs and locks and mutexes).

The current benchmarks floating around for STM , doesn’t look that promising, even when running on multi- core processors, which are very prevalent nowadays. Cliff of Azul systems makes a point in his blog , that under heavy load, the performance is unpredictable. Another article on ACMQueue gives us a “not very optimistic” viewpoint.

But I do believe that Sun’s hybrid transactional memory approach will eliminate many of these known limitations of STM alone (inability to distinguish between transactional execution vs non-transactional execution, user code being able to see in-consistent state inside an in-complete transaction etc).

The only silver lining is this latest paper, published by Sun at the Fourteenth International Conference on Architectural Support for Programming Languages and Operating Systems (ASPLOS ’09). It shows us that the folks at Sun have made great strides and the benchmark results sound very promising and makes us really believe that we are closer to mainstream adoption.

Time will tell.