views:

545

answers:

4

I was checking out Intel's "whatif" site and their Transactional Memory compiler (each thread has to make atomic commits or rollback the system's memory, like a Database would).

It seems like a promising way to replace locks and mutexes but I can't find many testimonials. Does anyone here have any input?

A: 

In some cases I can see this as being useful and even necessary.

However, even if the processor has special instructions that make this process easier there is still a large overhead compared to a mutex or semaphore. Depending on how it's implemented it may also impact realtime performance (have to either stop interrupts, or prevent them from writing into your shared areas).

My expectation is that if this was implemented, it would only be needed for portions of a given memory space, though, and so the impact could be limited.

Adam Davis
This doesn't sound like transactional memory... What is the overhead compared with mutexes and semaphores?
Andres Jaan Tack
There are several places where the overhead is higher. One obvious example is rolling back a transaction. It also makes caching more difficult and carry more overhead, as everything has to be immediate write-back to memory. Transactional memory is a good idea for some applications, but it does impact system performance, and thus shouldn't be deployed for every application and system.
Adam Davis
Ah, but multiple restarts are the pathological case for transactions. How does this compare with the pathological case for locks (long blocking, bouncing between caches)?
Andres Jaan Tack
+4  A: 

I have not used Intel's compiler, however, Herb Sutter had some interesting comments on it...

From Sutter Speaks: The Future of Concurrency

Do you see a lot of interest in and usage of transactional memory, or is the concept too difficult for most developers to grasp?

It's not yet possible to answer who's using it because it hasn't been brought to market yet. Intel has a software transactional memory compiler prototype. But if the question is "Is it too hard for developers to use?" the answer is that I certainly hope not. The whole point is it's way easier than locks. It is the only major thing on the research horizon that holds out hope of greatly reducing our use of locks. It will never replace locks completely, but it's our only big hope to replacing them partially.

There are some limitations. In particular, some I/O is inherently not transactional—you can't take an atomic block that prompts the user for his name and read the name from the console, and just automatically abort and retry the block if it conflicts with another transaction; the user can tell the difference if you prompt him twice. Transactional memory is great for stuff that is only touching memory, though.

Every major hardware and software vendor I know of has multiple transactional memory tools in R&D. There are conferences and academic papers on theoretical answers to basic questions. We're not at the Model T stage yet where we can ship it out. You'll probably see early, limited prototypes where you can't do unbounded transactional memory—where you can only read and write, say, 100 memory locations. That's still very useful for enabling more lock-free algorithms, though.

Brian Stewart
+1  A: 

Dr. Dobb's had an article on the concept last year: Transactional Programming by Calum Grant -- http://www.ddj.com/cpp/202802978

It includes some examples, comparisons, and conclusions using his example library.

Kris Kumler
+1  A: 

Sun Microsystems have announced that they're releasing a new processor next year, codenamed Rock, that has hardware support for transactional memory. It will have some limitations, but it's a good first step that should make it easier for programmers to replace locks/mutexes with transactions and expect good performance out of it.

For an interesting talk on the subject, given by Mark Moir, one of the researchers at Sun working on Transactional Memory and Rock, check out this link.

For more information and announcements from Sun about Rock and Transactional Memory in general, this link.

The obligatory wikipedia entry :)

Finally, this link, at the University of Wisconsin-Madison, contains a bibliography of most of the research that has been and is being done about Transactional Memory, whether it's hardware related or software related.

fuad