简体   繁体   English

原子操作与 STM

[英]Atomic Operation Vs STM


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 ie all the threads are incrementing a shared counter 50mn times, and noticed that atomic operation works better than STM.我在这两个上尝试了一些基准测试(软件事务 memory 和原子操作,我想两者都不一样),虽然我没有用 STM 做太多事情(似乎很难使用),但我成功地尝试了计算基准测试,即所有线程正在将共享计数器递增 5000 万次,并注意到原子操作比 STM 工作得更好。
So i want to know since STM are not fully developed, do they perform well in realistic situation than Atomic operation?所以我想知道,由于 STM 尚未完全开发,它们在现实情况下的表现是否比原子操作好?
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我在 web 上找到的相关期刊是无锁的并发编程

PS I am using JAVA as programming language. PS 我使用 JAVA 作为编程语言。 STM:- multi-verse. STM:-多节。 AtomicOperatinn: AtomicInteger. AtomicOperatinn:原子整数。

Atomic operations and STMs are very different beasts.原子操作和 STM 是非常不同的野兽。 In particular, atomic operations are much "lower level" constructs - in fact, atomic operations of various kinds are generally used to implement STM.特别是,原子操作是非常“低级”的结构——事实上,各种原子操作通常用于实现STM。 Basically:基本上:

  • An atomic operation allows you to do a concurrency-safe update of a single object .原子操作允许您对单个 object进行并发安全更新。 This is easy and fast, typically just a single instruction on modern hardware.这既简单又快速,通常只是现代硬件上的一条指令。
  • STM allows you do to a concurrency-safe update of multiple objects . STM 允许您对多个对象进行并发安全的更新。 This is complex.这很复杂。

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.因此,STM 系统需要增加额外的记账开销来管理事务更新的复杂性——因此,如果您只需要更新单个 object,原子操作几乎总是会更快。

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.此外,您应该知道,对于设计 STM 系统的最佳方法没有达成共识——这是一个活跃的研究课题,涉及许多权衡。 So what performs well on one STM system might not perform well on another STM system etc.因此,在一个 STM 系统上表现良好的东西可能在另一个 STM 系统上表现不佳等。

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.例如:我目前最喜欢的 STM 系统是 Clojure 的——它特别吸引人,因为它支持多版本并发控制,并且从不妨碍阅读器——这在许多常见场景中具有显着的性能优势。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM