Reputation: 2931
I was trying some benchmark over these two ( Software transactional memory & Atomic Operation , i guess both are not same ), though i have not done much using STM ( it seems hard to use ) ,but i successfully tried counting benchmark i.e. all the threads are incrementing a shared counter 50mn times, and noticed that atomic operation works better than STM.
So i want to know since STM are not fully developed , do they perform well in realistic situation than Atomic operation?
Has some one switched to other because of performance ? please share the information..
related journal i found on the web is Concurrent programming without locks
P.S. I am using JAVA as programming language. STM :- multi-verse. AtomicOperatinn: AtomicInteger.
Upvotes: 0
Views: 1112
Reputation: 106381
Atomic operations and STMs are very different beasts. In particular, atomic operations are much "lower level" constructs - in fact, atomic operations of various kinds are generally used to implement STM. Basically:
STM systems therefore need to add additional book-keeping overhead to manage the complexity of a transactional update - so if you only need to update a single object an atomic operation will nearly always be faster.
Also, you should be aware that there is no consensus on the best way to design STM systems - it's an active research topic and there are many tradeoffs involved. So what performs well on one STM system might not perform well on another STM system etc.
For example: my favourite STM system at the moment is Clojure's - it's particularly appealing because it supports multi-version concurrency control and never impedes readers - which gives a significant performance advantage in many common scenarios.
Upvotes: 9