<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Initial Forays into Transactional Memory Programming Models</title><link>http://blogs.msdn.com/stmteam/archive/2008/10/30/initial-forays-into-transactional-memory-programming-models.aspx</link><description>Welcome again to the TM blog! This time your host is Yossi Levanoni. I’m the dev lead on the TM project. It was great to see the high-quality questions we’ve gotten in response to Dana’s previous (and our altogether first) post on the blog and I’m looking</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Initial Forays into Transactional Memory Programming Models</title><link>http://blogs.msdn.com/stmteam/archive/2008/10/30/initial-forays-into-transactional-memory-programming-models.aspx#9027551</link><pubDate>Sat, 01 Nov 2008 03:27:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9027551</guid><dc:creator>barrkel</dc:creator><description>&lt;p&gt;You seem to have assumed away the basic problems of STM. How are developers supposed to decide what atomic{} needs to be wrapped around, and how are they going to be any better off than using lock{} as a result (modulo deadlocks, which are pretty trivial to fix given the stack traces)?&lt;/p&gt;
</description></item><item><title>re: Initial Forays into Transactional Memory Programming Models</title><link>http://blogs.msdn.com/stmteam/archive/2008/10/30/initial-forays-into-transactional-memory-programming-models.aspx#9028932</link><pubDate>Sun, 02 Nov 2008 09:13:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9028932</guid><dc:creator>Dave Detlefs</dc:creator><description>&lt;p&gt;This isn't just the basic problem of STM -- it's the basic problem of programming: what are the invariants that hold on data, and where do they hold? &amp;nbsp;Like locks, &amp;quot;atomic&amp;quot; needs to be wrapped around any region of code that accesses shared data, either a read access where we depend on getting an invariant-consistent view of multiple variables, or a write access where we temporarily violate (but then re-establish) invariants across shared variables. &amp;nbsp;I'm sorry we don't really know how to make this easier (but then I don't think anyone does.)&lt;/p&gt;
&lt;p&gt;I do think you sell the advantages of TM over lock-based programming a little short. &amp;nbsp;In my experience, maintaining lock orders in large programs can get *very* complicated. &amp;nbsp;And in a lot of other situations you have to invent total orders on objects in order to have a lock order. &amp;nbsp;(I have a set of bank accounts, each protected by a distinct lock, and I want to do a transfer from account A to account B -- which one do I lock first?) &amp;nbsp;And there's another problem associated with locking that goes away with transactions: keeping track of what lock protects what data? &amp;nbsp;That problem goes away with transactions, since you don't name locks explicitly.&lt;/p&gt;
&lt;p&gt;So programming with TM is still like programming with locks in many ways -- *but* without a lot of the complications.&lt;/p&gt;
</description></item><item><title>re: Initial Forays into Transactional Memory Programming Models</title><link>http://blogs.msdn.com/stmteam/archive/2008/10/30/initial-forays-into-transactional-memory-programming-models.aspx#9036333</link><pubDate>Tue, 04 Nov 2008 04:03:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9036333</guid><dc:creator>yossi.levanoni</dc:creator><description>&lt;p&gt;Hello Barrkel,&lt;/p&gt;
&lt;p&gt;It was my intention to elaborate on what we perceive as the advantages of TM only after we have described what TM is about to the less knowledgeable reader. So I wasn’t assuming this away as much as I was as saving it for later... You’re kind of jumping ahead of me.&lt;/p&gt;
&lt;p&gt;Having said that, I agree with the points Dave lists and we will elaborate on these and others. I’ll just list some additional buckets of value associated with TM and leave it at that for now: scalability through optimistic concurrency control, enhanced atomicity correctness (one of the points we are apparently in disagreement about) and enhanced reliability through failure atomicity. Not all advantages hold equally well in different embodiments of the technology.&lt;/p&gt;
&lt;p&gt;(Of course we’ll also have a hard look at the limitations of the technology, not only the benefits.)&lt;/p&gt;
</description></item><item><title>re: Initial Forays into Transactional Memory Programming Models</title><link>http://blogs.msdn.com/stmteam/archive/2008/10/30/initial-forays-into-transactional-memory-programming-models.aspx#9048653</link><pubDate>Thu, 06 Nov 2008 15:33:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9048653</guid><dc:creator>Dmitriy V'jukov</dc:creator><description>&lt;p&gt;Re: &amp;quot;We will explore these options in future blog posts but as a quick tip of the hat I would mention the work that our Intel colleagues have been doing on irrevocable actions [4]&amp;quot;&lt;/p&gt;
&lt;p&gt;Must some link be here?&lt;/p&gt;
</description></item><item><title>re: Initial Forays into Transactional Memory Programming Models</title><link>http://blogs.msdn.com/stmteam/archive/2008/10/30/initial-forays-into-transactional-memory-programming-models.aspx#9048992</link><pubDate>Thu, 06 Nov 2008 16:53:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9048992</guid><dc:creator>Dmitriy V'jukov</dc:creator><description>&lt;p&gt;I think that first thing one have to say wrt advantages of TM over locking it that 80% of lock-based code is not susceptible to dead-locks in any way shape or form. If code holds at most one lock at a time... well, what's the problem?&lt;/p&gt;
&lt;p&gt;Yes, there is 20% (or less) of involved situations, like classical example with bank accounts. And there are 2 time-proved simple solutions: ordered locking and hierarchical locking. Example with bank accounts can be solved trivially with ordered locking. Also it's possible to not hold read-locks, if we will allow more than 2 versions of object to coexist and writers will be just atomically replacing object with new version.&lt;/p&gt;
&lt;p&gt;If above doesn't help, or just gets too complicated, only here TM comes into play with it's non-susceptibility to dead-locks (live-locks aside for a moment). In involved situation TM can help indeed. But what's the problem with concurrent queue?&lt;/p&gt;
&lt;p&gt;Regarding lock-based queues and &amp;quot;scalability through optimistic concurrency control&amp;quot;. Well, all STM systems I've seen to date a kind of trying to bring the whole system to it's knees by hardly saturating coherence interconnects at the first opportunity. All those global timestamps, global lists of in-flight transactions, global descriptor tables etc. Yeah, there is theoretical possibility that &amp;quot;transaction on this end of the queue can run concurrently with transaction on that end of the queue, because they work on different data&amp;quot;. Will it take place? I mean real parallel work and real scalability, i.e. no modifications of global state, no reading of global state, only local processing.&lt;/p&gt;
&lt;p&gt;Especially taking into account that most current STM implementations are lock-based. I.e. if thread inside of transaction will be descheduled or will be waiting for HDD access (10 ms)... &amp;nbsp;Doesn't look superior to lock-based solutions... Just another set of caveats :)&lt;/p&gt;
</description></item><item><title>re: Initial Forays into Transactional Memory Programming Models</title><link>http://blogs.msdn.com/stmteam/archive/2008/10/30/initial-forays-into-transactional-memory-programming-models.aspx#9049026</link><pubDate>Thu, 06 Nov 2008 17:01:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9049026</guid><dc:creator>Dmitriy V'jukov</dc:creator><description>&lt;p&gt;Btw, I've described some of my thoughts about how it's probably possible to make STM really scalable (or at least get it close to performance of fine-grained locking) here:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://software.intel.com/en-us/forums/whatif-alpha-software/topic/60873/reply/64582/"&gt;http://software.intel.com/en-us/forums/whatif-alpha-software/topic/60873/reply/64582/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;and here:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://software.intel.com/en-us/forums/whatif-alpha-software/topic/61536/"&gt;http://software.intel.com/en-us/forums/whatif-alpha-software/topic/61536/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: Initial Forays into Transactional Memory Programming Models</title><link>http://blogs.msdn.com/stmteam/archive/2008/10/30/initial-forays-into-transactional-memory-programming-models.aspx#9049281</link><pubDate>Thu, 06 Nov 2008 17:55:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9049281</guid><dc:creator>Dmitriy V'jukov</dc:creator><description>&lt;p&gt;The main idea behind 'transactional contexts', which I've described in the links above, it that the only thing thread have to do in order to execute transaction on the object is to acquire single mutex *local* to the object. I.e. no instrumented accesses, no read/write set maintenance, no RAW conflict resolution, no quiescence for privatization-safety, no accesses to global state, no mutations of global state, no readset validation, no retries etc etc.&lt;/p&gt;
&lt;p&gt;It's a kind of safe reduction of full-fledged STM back to fine-grained locking.&lt;/p&gt;
&lt;p&gt;Btw, managed environment provides interesting possibilities for 'transactional contexts'. For example, 'transactional context' can be associated with object at run-time based on some heuristics. Or 'transactional context' (physically no more than rw-mutex) can be somehow combined with 'SyncBlk index' hidden field of managed object (so no static space overhead).&lt;/p&gt;
</description></item><item><title>re: Initial Forays into Transactional Memory Programming Models</title><link>http://blogs.msdn.com/stmteam/archive/2008/10/30/initial-forays-into-transactional-memory-programming-models.aspx#9049360</link><pubDate>Thu, 06 Nov 2008 18:09:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9049360</guid><dc:creator>Dmitriy V'jukov</dc:creator><description>&lt;p&gt;Here is another interesting moment regarding semantics and features STM can provide - partial commits.&lt;/p&gt;
&lt;p&gt;Assume we are iterating over lengthy linked-list, probably doing some processing for every item, or just searching for some node. Further assume we don't need total global atomicity/consistency wrt whole list (otherwise probably it will be 100% livelock), we need only local atomicity/consistency. I.e., for example, when we are processing node, we definitely don't want to process already removed node; but we don't require that no nodes was inserted into beginning of the list.&lt;/p&gt;
&lt;p&gt;With locks we can do following. Lock node, process node, lock next node, unlock current node, process next node, lock next after next node and so on.&lt;/p&gt;
&lt;p&gt;But we can mimic it with &amp;quot;atomic {}&amp;quot; syntax, because per-node transactions are overlapping!&lt;/p&gt;
</description></item><item><title>re: Initial Forays into Transactional Memory Programming Models</title><link>http://blogs.msdn.com/stmteam/archive/2008/10/30/initial-forays-into-transactional-memory-programming-models.aspx#9054902</link><pubDate>Sun, 09 Nov 2008 04:31:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9054902</guid><dc:creator>yossi.levanoni</dc:creator><description>&lt;p&gt;Dmitriy,&lt;/p&gt;
&lt;p&gt;Thanks for pointing the broken citation for the Intel irrevocable actions work---I fixed it.&lt;/p&gt;
&lt;p&gt;You raise some good points in your comments.&lt;/p&gt;
&lt;p&gt;On the deadlock question, I would agree that many lock uses are &amp;quot;leaf locks&amp;quot; and are not susceptible to deadlocks. Many of these locks are also just there in order to do lazy-initialization, and this is something that we'll be helping developers with using all sorts of LazyInit classes. Still one has to wonder what fraction of these 80% (let's just take this number at face value for the sake of discussion) over time become non-leaf locks and whether the developer who is modifying the code is aware of the previous leaf-level assumptions. It takes just a small fraction of such mistakes to create bugs that are extremely costly to fix, if they are not caught on time. Regarding the rest 20% that are more complicated, some of them are &amp;quot;trivial&amp;quot; as you say but many are not at all so, and I'm taking a note to talk about this more.&lt;/p&gt;
&lt;p&gt;Your comment on whether scalability is really possible in a real implementation, where you express skepticism about whether the system introduces its own scalability bottlenecks, when the application doesn't have any such bottlenecks, is also a good one. One concept that we use to evaluate the quality of implementations is *parallelism preservation* i.e. whether the system scales as a whole when the application access pattern indicate that such scaling is possible. Many implementations, for example TL2, are not parallelism preserving, since they contain contention on a global counter. With higher core counts this serialization effect is definitely visible. The Bartok STM is implemented using an algorithm that is extremely scalable and is to the best of my knowledge as close at you can get to true parallelism preservation. Published results indicate indeed very good scalability and our internal experiments confirm this.&lt;/p&gt;
&lt;p&gt;Your observations on &amp;quot;transactional contexts&amp;quot; (I think maybe &amp;quot;data capsules&amp;quot; are a better term :-) remind me of a class of interesting work combining static and dynamic lock assignment based on data accessibility. Two interesting papers on this are:&lt;/p&gt;
&lt;p&gt;Enforcing isolation and ordering in STM (from Intel research)&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://portal.acm.org/citation.cfm?id=1250734.1250744"&gt;http://portal.acm.org/citation.cfm?id=1250734.1250744&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Inferring Locks for Atomic Sections (from Microsoft research)&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://research.microsoft.com/research/pubs/view.aspx?type=Technical%20Report&amp;amp;id=1354"&gt;http://research.microsoft.com/research/pubs/view.aspx?type=Technical%20Report&amp;amp;id=1354&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Most of these approaches require full program analysis and the ability to preclude aliasing of the data that is to be protected, which is sometimes not extremely practical, although the Intel paper explains how you can work with &amp;quot;incremental whole program analysis&amp;quot; that needs to re-JIT code once invariants are broken due to the loading of new code. Having said that, we're sure that there are a *ton* of optimizations of this nature that are possible and this is one of the reasons why we are still optimistic regarding the sequential performance cost of software TM...&lt;/p&gt;
&lt;p&gt;Your last comment raises the question of whether it will be possible to do with TM things like hand-over-hand locking, prune things out of your transactional state etc. Some STM's that are out there allow you to do such things, at the cost of divulging a lot of implementation details. It's certainly possible, but we hope that such &amp;quot;tricks&amp;quot; will not be necessary in the common cases where people would want to use &amp;quot;atomic&amp;quot; blocks.&lt;/p&gt;
&lt;p&gt;Thanks for all the feedback!&lt;/p&gt;
</description></item><item><title>re: Initial Forays into Transactional Memory Programming Models</title><link>http://blogs.msdn.com/stmteam/archive/2008/10/30/initial-forays-into-transactional-memory-programming-models.aspx#9157126</link><pubDate>Sun, 30 Nov 2008 07:59:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9157126</guid><dc:creator>Joe Cromwell</dc:creator><description>&lt;p&gt;Very intriguing... I wonder how transactions in C# interface with low level system code written in C++? Say I have some utilities I wrote in C++ that are called from C#. Today I use locks in C# to avoid problems. What would be the means to do the same in atomic world? Would I need to change my C++ code?&lt;/p&gt;
</description></item></channel></rss>