首页 > 技术相关, 芯片设计 > 事务和事务内存

事务和事务内存

2012年2月12日 发表评论 阅读评论

今天(2月9日),看到solidot报道,英特尔下一代Haswell处理器硬件支持事务内存,感觉有点小意外。

其实很早以前(2009年),我就对事务内存关注过一段时间,当时,号称要支持的事务内存的处理器只有(据我所知)只有sun公司的Rock处理器,可是这个Rock,一再跳票,跳到Sun陨落也没发布,到现在,oracle也没发布支持事务内存的处理器。事务内存(尤其是硬件实现的)的前景貌似不太明朗。

2011年9月,IBM发布了BlueGene/Q处理器,这是第一款支持事务内存的处理器。但是,这并不意味着事务内存重见天日了。
2012年2月7日,最大的处理器厂商发表文章,声称支持硬件事务内存,其通过Transactional Synchronization Extensions(TSX)的组件来实现的,事务内存的前景终于开始明朗起来。

那么,什么是事务,什么又是事务内存呢。

根据维基百科整理,事务的定义为:

数据库事务(简称: 事务)是数据库管理系统执行过程中的一个逻辑单位,由一个有限的数据库操作序列构成。在数据库管理系统中,事务必须满足ACID性质,即原子性,一致性,隔离性和持久性。原子性指的是事务中的动作要么全部执行,要么一个都不执行;一致性指的是任何时刻,数据库必须处于一致性状态,即必须满足某些预先设定的条件;隔离性是指一个事务不能看见其他未提交事务所涉及到的内部对象的状态,而持久性则是指一个已提交的事务对数据库系统的改变必须是永久的。

那事务内存又是什么,根据国防科大张铎等人的《事务存储结构的实现》一文,事务内存是这样介绍的(为了准确,以下为直接引文,完成内存详见《事务存储结构的实现》一文):

随着多核处理器技术的不断更新和发展,传统的串行程序不论在效率上还是性能上都已经跟不上信息高速发展的脚步了,程序员不得不开发线程级并行以提高片上计算资源的使用效率,但也带来了新的挑战和问题。目前不同线程间的同步、对共享资源的访问等都是通过锁和信号量机制完成的。然而,这种传统的基于锁和信号量的并发系统存在明显的局限性。粗粒度的锁对大量的共享数据做了保护,但是可扩展性不好,因为即使在线程间不存在对共享数据的访问的情况下也可能会出现冲突阻塞现象;细粒度的锁虽然比粗粒度的锁扩展性能好,但由于算法设计的复杂性,普通程序员很难借助细力度的锁实现高效的应用。同时使用锁机制还会带来诸多问题,比如:死锁、优先级反转等,极大地影响了并行应用的效率和性能。

事务存储(Transactional Memory,TM)的使用是解决上述存在问题一个很好的办法[1]。通过将不同并行执行的线程事务化,用事务操作来代替锁机制能降低编程的复杂性。事务是被单线程执行的对内存进行读写的有序操作序列,其特性包括:原子性、隔离性、一致性和持久性。通常事务的执行过程为:调用事务入口函数(begin_transaction)开始执行事务,当事务执行完毕后调用提交函数(commit_transaction)开始提交工作,提交过程分为三个阶段(请求提交、开始提交和完成提交),执行完提交后此事务也就执行完毕,从而继续执行下面的事务。但如果事务在执行或提交过程中发生冲突或者错误,则通过其特有的回滚机制 (rollback)返回到此事务入口继续执行。

为了实现事务的这些特性,需有一个很好的TM系统来支持事务数据的版本管理(Version Management)和事务的冲突管理(Contention Management)。版本管理同时对新值(事务提交后可见)和原始的旧值(事务执行过程中发生了回滚的恢复数据)进行管理。根据数据存放方式的不同TM系统区分版本管理为:积极版本管理(Eager Version Management)和懒惰版本管理(Lazy Version Management)。积极版本管理是将新值置于目标存储区中,这样在提交时新值能够很快的得到执行,极大地降低了提交的时延;而懒惰版本管理是将原始的旧值置于目标存储区,虽然会增加提交的延时但是降低了当事务发生回滚后执行的延时。冲突管理是不同事务执行过程中对共享资源访问引发冲突而进行的冲突检测以及管理的机制。冲突管理有积极的(Eager)和懒惰的(Lazy)两种策略,如果冲突在读数据或写数据时立刻被发现而进行仲裁,这种冲突检测是积极的;如果冲突是在事务进行提交时才发现并仲裁的,这种冲突检测则是懒惰的。

可以看出,事务内存的出现就是为了解决并行编程存储一致性和性能矛盾的问题,传统的锁机制会导致性能低下,并且可扩展星差,而事务内存,则尝试在体系结构和程序员之间定义一个新的一致性,也即事务一致性,对应的内存模型叫做事务内存。从上面一段话可以看出,硬件事务内存有很多问题需要解决,包括版本管理,以及冲突管理,而对于硬件,只有有限的资源,因此,这就限制了事务的长度,使(硬件)事务内存的实现难度和实用性大大降低,这也许是Rock难产的原因之一。



本文作者: Sigma    在新浪微博关注SigmaSigmaWeibo    RSS订阅本博客
本文链接: http://www.sigma.me/2012/02/12/transaction-and-transaction-memor.html
本博客采用知识共享署名—非商业性-禁止演绎使用3.0协议进行许可,转载请保留作者和原文链接。

  1. 2019年1月15日07:11 | #1

    I would like to convey my love for your kindness supporting visitors who have the need for help on the idea. Your very own commitment to passing the solution throughout came to be certainly interesting and has without exception made folks like me to attain their aims. Your personal informative guidelines implies this much to me and a whole lot more to my peers. Thanks a lot; from all of us.

  2. 2019年1月15日15:43 | #2

    I and also my buddies appeared to be going through the best guides located on the website while all of the sudden I got an awful suspicion I had not thanked the web blog owner for those tips. All the ladies were definitely so thrilled to see all of them and already have absolutely been taking pleasure in them. We appreciate you getting quite thoughtful and then for deciding upon such wonderful ideas most people are really desperate to know about. Our own sincere apologies for not saying thanks to you earlier.

  3. 2019年1月16日01:39 | #3

    Thank you for your whole hard work on this web site. My daughter enjoys carrying out investigation and it is obvious why. Almost all hear all regarding the lively means you make very useful items via this website and in addition inspire contribution from website visitors on that topic then our own simple princess is certainly being taught a lot of things. Take pleasure in the remaining portion of the year. You’re performing a glorious job.

  4. 2019年1月16日09:05 | #4

    Thanks a lot for giving everyone such a breathtaking chance to read articles and blog posts from this site. It’s always so enjoyable and also packed with a great time for me personally and my office acquaintances to visit the blog at least thrice in a week to read through the new guidance you have. Of course, I am just usually contented with your gorgeous hints you serve. Certain 3 tips on this page are clearly the best I have had.

  5. 2019年1月16日17:12 | #5

    I and also my buddies happened to be checking out the best recommendations from your site and quickly got a horrible feeling I had not thanked the blog owner for those tips. All of the people were as a result joyful to see all of them and have in effect sincerely been tapping into these things. We appreciate you getting simply helpful as well as for making a decision on this sort of magnificent things millions of individuals are really needing to understand about. My personal sincere apologies for not saying thanks to sooner.

  6. 2019年1月16日18:11 | #6

    I precisely had to appreciate you again. I’m not certain the things I might have gone through without the actual suggestions provided by you relating to my subject matter. It had been a real fearsome situation in my opinion, but understanding the very skilled way you solved the issue made me to jump for happiness. I am thankful for the assistance and in addition hope that you know what a great job you are providing teaching others with the aid of a blog. Most probably you have never encountered any of us.

  7. 2019年1月17日04:34 | #7

    I actually wanted to construct a small message in order to thank you for all of the fabulous information you are giving at this site. My extended internet lookup has at the end of the day been paid with professional insight to exchange with my pals. I ‘d say that we readers are unequivocally lucky to dwell in a very good site with many marvellous people with beneficial tips. I feel truly happy to have encountered your entire weblog and look forward to many more enjoyable moments reading here. Thanks a lot once again for everything.

  8. 2019年1月17日12:20 | #8

    I precisely wanted to thank you so much once again. I’m not certain what I would’ve implemented in the absence of the actual tactics documented by you directly on this topic. It absolutely was a real frightening crisis in my circumstances, however , witnessing a new specialized tactic you treated it took me to weep with contentment. Now i’m grateful for the support and as well , hope you comprehend what an amazing job you’re putting in instructing the others all through a site. Probably you’ve never met any of us.

  9. 2019年1月17日21:52 | #9

    I just wanted to develop a quick note to say thanks to you for those splendid steps you are posting on this site. My long internet research has at the end of the day been recognized with pleasant ideas to talk about with my friends and family. I ‘d mention that we site visitors are very much endowed to live in a really good network with very many special individuals with very helpful advice. I feel somewhat lucky to have seen the weblog and look forward to many more fun moments reading here. Thanks a lot once more for all the details.

  10. 2019年1月18日06:30 | #10

    I must voice my gratitude for your kind-heartedness supporting those people who need guidance on in this field. Your very own commitment to getting the message all-around appeared to be astonishingly valuable and have specifically helped somebody much like me to arrive at their goals. Your entire interesting tutorial means this much a person like me and even further to my office colleagues. Many thanks; from each one of us.

  11. 2019年1月18日13:49 | #11

    I not to mention my pals ended up reading through the great secrets and techniques from your web site and so immediately came up with a horrible suspicion I never thanked the site owner for those techniques. The young men came certainly very interested to see all of them and have in effect surely been tapping into these things. Thank you for actually being quite kind and for picking these kinds of quality topics millions of individuals are really eager to discover. Our sincere regret for not expressing appreciation to you earlier.

  12. 2019年1月18日22:59 | #12

    I simply wanted to appreciate you once more. I am not sure the things I might have taken care of without the type of methods documented by you about such a concern. It seemed to be a real frightening setting for me personally, however , considering a new skilled strategy you solved it took me to jump with gladness. I am happy for the work and as well , trust you realize what a great job you are accomplishing instructing others using a web site. I am certain you’ve never got to know all of us.

  13. 2019年1月19日06:36 | #13

    I simply needed to thank you very much once more. I am not sure the things I would have followed without the actual tactics provided by you over such industry. Certainly was the frightful concern in my position, however , encountering a new skilled approach you handled it made me to leap over joy. I am just thankful for your guidance and as well , expect you know what an amazing job you are accomplishing educating men and women through your web page. Most probably you have never met any of us.

  14. 2019年1月19日12:41 | #14

    Needed to write you one bit of word just to thank you over again for your personal precious techniques you’ve contributed in this article. This is certainly remarkably generous of you to present extensively precisely what a few people could possibly have made available as an electronic book in making some bucks for themselves, notably since you could possibly have tried it in case you wanted. Those concepts also served to provide a good way to realize that most people have the identical interest just like mine to know the truth good deal more when it comes to this condition. I’m sure there are many more pleasant opportunities up front for people who discover your site.

  15. 2019年1月20日00:22 | #15

    Thank you for your own effort on this blog. Kim really likes setting aside time for investigations and it’s simple to grasp why. We hear all relating to the dynamic tactic you render invaluable tips and tricks by means of this web site and even attract contribution from website visitors on the topic while our own daughter is being taught so much. Take pleasure in the remaining portion of the year. You are performing a terrific job.

  16. 2019年1月20日07:21 | #16

    I simply desired to thank you so much once more. I’m not certain what I would have done in the absence of the type of points provided by you directly on such situation. It became a real frightful issue for me personally, however , discovering your specialised fashion you treated that made me to jump for happiness. I’m just happy for this guidance and then hope that you comprehend what a great job that you are accomplishing educating other individuals all through your webblog. More than likely you’ve never encountered any of us.

  17. 2019年1月20日15:48 | #17

    I want to express my appreciation to the writer just for rescuing me from this type of trouble. After looking out through the world wide web and seeing ideas which are not beneficial, I believed my life was over. Existing without the presence of solutions to the issues you have sorted out as a result of your short article is a serious case, as well as the kind which may have badly affected my career if I hadn’t encountered your site. Your personal understanding and kindness in maneuvering every part was invaluable. I don’t know what I would have done if I hadn’t discovered such a stuff like this. I’m able to at this time look ahead to my future. Thanks so much for this professional and sensible help. I won’t hesitate to endorse the blog to any person who ought to have guidance on this matter.

  18. 2019年1月21日01:34 | #18

    I have to express appreciation to this writer just for bailing me out of such a issue. After searching throughout the world-wide-web and obtaining things that were not powerful, I thought my entire life was done. Being alive without the presence of approaches to the difficulties you have solved as a result of your blog post is a crucial case, as well as those that would have in a negative way affected my entire career if I had not discovered your web blog. The competence and kindness in handling all the pieces was precious. I don’t know what I would have done if I had not encountered such a thing like this. I can also at this moment relish my future. Thank you very much for this impressive and effective help. I won’t be reluctant to endorse the sites to any person who needs and wants guidelines about this area.

  19. 2019年1月21日08:07 | #19

    Thanks so much for giving everyone an extremely special chance to read in detail from this blog. It’s usually very good plus full of a lot of fun for me and my office friends to visit your website the equivalent of 3 times per week to find out the fresh tips you have. And lastly, I am just certainly motivated with all the remarkable inspiring ideas served by you. Selected two tips in this article are rather the most suitable I have had.

  20. 2019年1月21日15:19 | #20

    A lot of thanks for all your effort on this website. My daughter really loves carrying out internet research and it’s easy to see why. Most people know all concerning the lively way you produce informative information on this website and strongly encourage response from the others about this topic while our simple princess is actually discovering a whole lot. Take pleasure in the remaining portion of the new year. Your carrying out a pretty cool job.

  21. 2019年1月22日01:28 | #21

    I simply wanted to say thanks all over again. I’m not certain what I would have tried in the absence of the tips and hints contributed by you about my field. It previously was a very traumatic difficulty in my view, however , coming across the very specialised way you resolved it took me to weep over contentment. I’m happier for your service as well as have high hopes you really know what a powerful job you were providing educating other individuals with the aid of your websites. Most probably you have never encountered any of us.

  22. 2019年1月22日09:37 | #22

    Thanks so much for giving everyone remarkably pleasant possiblity to read in detail from this site. It is often very great and as well , full of a good time for me and my office acquaintances to visit your web site not less than thrice weekly to see the new secrets you have. And lastly, I am certainly fulfilled concerning the splendid ideas served by you. Selected two areas in this post are particularly the most efficient I’ve ever had.

  23. 2019年1月22日10:24 | #23

    My wife and i have been glad when Raymond managed to conclude his homework using the ideas he received out of the web site. It’s not at all simplistic just to happen to be giving for free instructions which often a number of people could have been trying to sell. Therefore we remember we now have the website owner to thank because of that. The specific illustrations you made, the easy website menu, the relationships you will make it easier to foster – it’s got everything extraordinary, and it’s really aiding our son and our family consider that that situation is satisfying, which is certainly rather important. Many thanks for all the pieces!

  24. 2019年1月22日17:49 | #24

    A lot of thanks for all of your efforts on this web site. Ellie really loves conducting internet research and it’s really easy to see why. My spouse and i learn all about the dynamic way you give informative information by means of this web site and therefore attract participation from some others about this subject matter and our own girl is without a doubt learning a whole lot. Enjoy the rest of the new year. You’re performing a tremendous job.

  1. 本文目前尚无任何 trackbacks 和 pingbacks.

无觅相关文章插件,快速提升流量