问题描述
我一直在从事事务性内存及其在系统编程(数据库,操作系统,服务器等)上的可行性方面的工作.我自己在使用事务时的经验,以及看到有多少社区在真实代码中使用事务,引发了一个问题:什么能说服您(编写生产代码的开发人员)在您的工作中使用事务内存?
I've been doing some work on transactional memory and its viability for systems programming (databases, operating systems, servers, etc.). My own experience employing transactions, together with having seen how few communities use transactions in real code, has raised a question: What would convince you, a developer writing production code, to employ transactional memory in your work?
会被普遍采用吗?高速?可靠性提高了吗?多少钱?
Would it be general adoption? High speed? Improved reliability? By how much?
对于那些没有看到它们的人,内存事务就像数据库事务一样:操作(显然)并行进行,并且如果两个事务之间存在冲突(例如,它们都写入相同的值),则一个或两个的事务将被回滚并重新启动.
For those that haven't seen them, memory transactions act like database transactions: operations proceed (apparently) in parallel, and if there is a conflict between two transactions (e.g. they both write the same value), then one or both of the transactions will be rolled back and restarted.
事务性内存有一些好处:
Transactional memory has a few benefits:
- 可靠性,完全摆脱了死锁(例如,错误顺序的锁定).
- 性能,当锁争用程度较低时,速度更快.
- 可编程性,细粒度的并发控制,无需管理许多同步对象.
- Reliability Complete freedom from deadlocks (e.g. wrong-order locking).
- Performance Greater speed when there is low contention for locks.
- Programmability Fine-grain concurrency control without many synchronization objects to manage.
即使假设TM的正确,完整和快速实现,但是与锁相比,该原语也存在不利之处.
Even assuming a correct, complete, and fast implementation of TM, however, there are known downsides to this primitive when compared with locks.
-
由于事务可能执行多次,因此除经验实验外,更难预测性能.
Since transactions might execute several times, it is more difficult to predict performance except by empirical experiment.
我们可以重现性能错误吗?
在某些正确的实现之间,有一些政策决定会有所不同,例如在另一笔交易中结束的一笔交易会如何处理?我们现在提交还是等待?
There are some policy decisions that differ between correct implementations, e.g. What happens to a transaction that ends inside another transaction? Do we commit now, or do we wait?
我们可以充分理解代码的局部影响吗?
为了在回滚的事务中支持不可撤销的行为(例如发送发射导弹"命令),运行时变得更加复杂.
In order to support irrevocable behavior (e.g. sending the "fire missiles" command) in a transaction that is rolled back, the runtime becomes more complex.
我们能否充分理解代码的全局影响?
最后,由于软件实现可能是第一个被使用的(仅举几个例子,就已经有C,C ++,Haskell,Clojure和Scala的实现),实际上存在性能问题.在争用适度的情况下,软件交易会带来性能上的损失.
Lastly, as Software implementations will probably be the first to be used (there are already implementations in C, C++, Haskell, Clojure and Scala, to name a few), there actually is a performance problem. With moderate contention, software transactions come with a performance hit.
您的绩效预算是多少?在什么时候收益大于潜在成本?
推荐答案
几件事:
1)软件事务存储(STM)系统必须健壮,可靠并且经过测试,才能真正起作用.
1) The Software Transactional Memory (STM) System would have to be robust, reliable, and tested so that it actually works.
2)无争议的STM事务的性能开销应与具有无争议的锁的同一例程相当.
2) The performance overhead of an uncontested STM transaction should be comparable to the same routine with a uncontested lock.
3)与有争议的资源锁定相比,在有多个事务待处理的情况下,STM系统必须具有更好的性能.
3) The STM system must perform significantly better when multiple transactions are pending vs using a lock on contested resources.
这篇关于要使事务性内存可行,需要做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!