<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Programming with Concurrency</title>
	<atom:link href="http://danweinreb.org/blog/programming-with-concurrency/feed" rel="self" type="application/rss+xml" />
	<link>http://danweinreb.org/blog/programming-with-concurrency</link>
	<description>Software and Innovation</description>
	<lastBuildDate>Wed, 01 Sep 2010 14:32:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Vadim</title>
		<link>http://danweinreb.org/blog/programming-with-concurrency/comment-page-1#comment-42471</link>
		<dc:creator>Vadim</dc:creator>
		<pubDate>Fri, 26 Feb 2010 22:22:17 +0000</pubDate>
		<guid isPermaLink="false">http://danweinreb.org/blog/?p=184#comment-42471</guid>
		<description>Re: Knuth&#039;s alleged ignorance of True Meaning of Moore&#039;s Law...

As early as 2001 (ISBN-10: 157586326X), he said (right here, in
Cambridge): &quot;Moore&#039;s Law certainly can&#039;t go on indefinitely.&quot;

Re: &quot;Sundar is my boss at ITA, and is quite awesome&quot;.

That was quite funny.</description>
		<content:encoded><![CDATA[<p>Re: Knuth&#8217;s alleged ignorance of True Meaning of Moore&#8217;s Law&#8230;</p>
<p>As early as 2001 (ISBN-10: 157586326X), he said (right here, in<br />
Cambridge): &#8220;Moore&#8217;s Law certainly can&#8217;t go on indefinitely.&#8221;</p>
<p>Re: &#8220;Sundar is my boss at ITA, and is quite awesome&#8221;.</p>
<p>That was quite funny.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Weinreb</title>
		<link>http://danweinreb.org/blog/programming-with-concurrency/comment-page-1#comment-33709</link>
		<dc:creator>Dan Weinreb</dc:creator>
		<pubDate>Wed, 23 Sep 2009 11:03:11 +0000</pubDate>
		<guid isPermaLink="false">http://danweinreb.org/blog/?p=184#comment-33709</guid>
		<description>In the Knuth interview that Sundar referenced about, Knuth refers to the &quot;future demise of Moore&#039;s Law&quot;.  I wonder if he is interpreting Moore&#039;s law to say that the speed of instruction execution of CPU&#039;s keeps going up at some rate.  Actually it&#039;s about the number of transistors on an integrated circuit.

Here&#039;s an interesting article that came out today in NetworkWorld quoting Intel CTO Justin Rattner saying that Moore&#039;s Law has lots more time to run.

http://www.networkworld.com/news/2009/092209-intel-cto-moores-law.html?source=NWWNLE_nlt_daily_am_2009-09-23

Make your own judgment about how to balance the fact that this guy knows a lot about the topic but might have a vested interest in public perception.  But the demise of silicon has been predicted for a LONG time. If you&#039;re at least as old as me, you&#039;ll remember when Josephson Junctions were going to take over from silicon; that was quite a long time ago. And Rattner is hardly the only person making this claim.  Time will tell.</description>
		<content:encoded><![CDATA[<p>In the Knuth interview that Sundar referenced about, Knuth refers to the &#8220;future demise of Moore&#8217;s Law&#8221;.  I wonder if he is interpreting Moore&#8217;s law to say that the speed of instruction execution of CPU&#8217;s keeps going up at some rate.  Actually it&#8217;s about the number of transistors on an integrated circuit.</p>
<p>Here&#8217;s an interesting article that came out today in NetworkWorld quoting Intel CTO Justin Rattner saying that Moore&#8217;s Law has lots more time to run.</p>
<p><a href="http://www.networkworld.com/news/2009/092209-intel-cto-moores-law.html?source=NWWNLE_nlt_daily_am_2009-09-23" rel="nofollow">http://www.networkworld.com/news/2009/092209-intel-cto-moores-law.html?source=NWWNLE_nlt_daily_am_2009-09-23</a></p>
<p>Make your own judgment about how to balance the fact that this guy knows a lot about the topic but might have a vested interest in public perception.  But the demise of silicon has been predicted for a LONG time. If you&#8217;re at least as old as me, you&#8217;ll remember when Josephson Junctions were going to take over from silicon; that was quite a long time ago. And Rattner is hardly the only person making this claim.  Time will tell.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Weinreb</title>
		<link>http://danweinreb.org/blog/programming-with-concurrency/comment-page-1#comment-33572</link>
		<dc:creator>Dan Weinreb</dc:creator>
		<pubDate>Sun, 20 Sep 2009 14:55:30 +0000</pubDate>
		<guid isPermaLink="false">http://danweinreb.org/blog/?p=184#comment-33572</guid>
		<description>I&#039;d like to clarify the earlier comment from Sundar Narasimhan: the part starting with &quot;Donald:&quot; is a quotation from Donald Knuth.  (I know that this was supposed to be clear from the context and typography, but I was confused so I thought other readers of the blog might be.)  (Sundar is my boss at ITA, and is quite awesome, so I take this opinions extremely seriously!)

The rest of Knuth&#039;s answer is very interesting, too.  He goes on to say:

&quot;...turns out to be a flop, worse than the &quot;Itanium&quot; approach that was supposed to be so terrific—until it turned out that the wished-for compilers were basically impossible to write.

Let me put it this way: During the past 50 years, I’ve written well over a thousand programs, many of which have substantial size. I can’t think of even five of those programs that would have been enhanced noticeably by parallelism or multithreading. Surely, for example, multiple processors are no help to TeX.[1]

How many programmers do you know who are enthusiastic about these promised machines of the future? I hear almost nothing but grief from software people, although the hardware folks in our department assure me that I’m wrong.

I know that important applications for parallelism exist—rendering graphics, breaking codes, scanning images, simulating physical and biological processes, etc. But all these applications require dedicated code and special-purpose techniques, which will need to be changed substantially every few years.&quot;

I&#039;m not so sure that these programs will have to be substantially rewritten every few years.  The concept of threads does not seem to be quite that ephemeral.

I have just started reading (on my Kindle!) the book &quot;The Art of Multiprocessor Programming&quot;, by Maurice Herlihy of Brown U. and Nir Shavit of Tel-Aviv U. and Sun Microsystems.  There&#039;s an extensive review at Amazon saying what all the chapters are and what&#039;s covered.  I&#039;m guessing that what I hope to learn from this book will be valuable for many years.  We&#039;ll see, I guess.</description>
		<content:encoded><![CDATA[<p>I&#8217;d like to clarify the earlier comment from Sundar Narasimhan: the part starting with &#8220;Donald:&#8221; is a quotation from Donald Knuth.  (I know that this was supposed to be clear from the context and typography, but I was confused so I thought other readers of the blog might be.)  (Sundar is my boss at ITA, and is quite awesome, so I take this opinions extremely seriously!)</p>
<p>The rest of Knuth&#8217;s answer is very interesting, too.  He goes on to say:</p>
<p>&#8220;&#8230;turns out to be a flop, worse than the &#8220;Itanium&#8221; approach that was supposed to be so terrific—until it turned out that the wished-for compilers were basically impossible to write.</p>
<p>Let me put it this way: During the past 50 years, I’ve written well over a thousand programs, many of which have substantial size. I can’t think of even five of those programs that would have been enhanced noticeably by parallelism or multithreading. Surely, for example, multiple processors are no help to TeX.[1]</p>
<p>How many programmers do you know who are enthusiastic about these promised machines of the future? I hear almost nothing but grief from software people, although the hardware folks in our department assure me that I’m wrong.</p>
<p>I know that important applications for parallelism exist—rendering graphics, breaking codes, scanning images, simulating physical and biological processes, etc. But all these applications require dedicated code and special-purpose techniques, which will need to be changed substantially every few years.&#8221;</p>
<p>I&#8217;m not so sure that these programs will have to be substantially rewritten every few years.  The concept of threads does not seem to be quite that ephemeral.</p>
<p>I have just started reading (on my Kindle!) the book &#8220;The Art of Multiprocessor Programming&#8221;, by Maurice Herlihy of Brown U. and Nir Shavit of Tel-Aviv U. and Sun Microsystems.  There&#8217;s an extensive review at Amazon saying what all the chapters are and what&#8217;s covered.  I&#8217;m guessing that what I hope to learn from this book will be valuable for many years.  We&#8217;ll see, I guess.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Weinreb</title>
		<link>http://danweinreb.org/blog/programming-with-concurrency/comment-page-1#comment-33571</link>
		<dc:creator>Dan Weinreb</dc:creator>
		<pubDate>Sun, 20 Sep 2009 14:42:16 +0000</pubDate>
		<guid isPermaLink="false">http://danweinreb.org/blog/?p=184#comment-33571</guid>
		<description>I am very unaccustomed to disagreeing with Dave Moon.  I had the privilege of working closely with him for at least twenty years, and although there have been a few times when he was actually wrong about something, they were very few and far between.  To get some more insight on these issues, I turned to another friend who knows a great deal about this,and whom I hold in as high esteem as I do Dave Moon, namely, Guy Steele.  He sent me this reply and gave me permission to publish it here:

&quot;I think you&#039;re all right, because you&#039;re talking about slightly different things.  Moon is right that that when creating and initializing an immutable object, great care is required between the initialization and the publishing of the pointer to that object to other threads.  This was a big problem with the first version of the Java memory model, for example; Bill Joy and I had overlooked some of the subtleties associated with object initialization.  Moon is also right that this is best left to &quot;professionals&quot;, and I think everyone agrees that the high-level functional programming abstraction allows the fiddly details of keeping the hardware happy with memory-fence instructions or whatever to be buried where the application programmer never has to see them---but there is a (necessary) performance cost.&quot;</description>
		<content:encoded><![CDATA[<p>I am very unaccustomed to disagreeing with Dave Moon.  I had the privilege of working closely with him for at least twenty years, and although there have been a few times when he was actually wrong about something, they were very few and far between.  To get some more insight on these issues, I turned to another friend who knows a great deal about this,and whom I hold in as high esteem as I do Dave Moon, namely, Guy Steele.  He sent me this reply and gave me permission to publish it here:</p>
<p>&#8220;I think you&#8217;re all right, because you&#8217;re talking about slightly different things.  Moon is right that that when creating and initializing an immutable object, great care is required between the initialization and the publishing of the pointer to that object to other threads.  This was a big problem with the first version of the Java memory model, for example; Bill Joy and I had overlooked some of the subtleties associated with object initialization.  Moon is also right that this is best left to &#8220;professionals&#8221;, and I think everyone agrees that the high-level functional programming abstraction allows the fiddly details of keeping the hardware happy with memory-fence instructions or whatever to be buried where the application programmer never has to see them&#8212;but there is a (necessary) performance cost.&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sundar Narasimhan</title>
		<link>http://danweinreb.org/blog/programming-with-concurrency/comment-page-1#comment-32627</link>
		<dc:creator>Sundar Narasimhan</dc:creator>
		<pubDate>Sat, 29 Aug 2009 23:47:33 +0000</pubDate>
		<guid isPermaLink="false">http://danweinreb.org/blog/?p=184#comment-32627</guid>
		<description>Interesting thread Dan -- Knuth for one agrees with Dave Moon above.
....
Donald: I don’t want to duck your question entirely. I might as well flame a bit about my personal unhappiness with the current trend toward multicore architecture. To me, it looks more or less like the hardware designers have run out of ideas, and that they’re trying to pass the blame for the future demise of Moore’s Law to the software writers by giving us machines that work faster only on a few key benchmarks! I won’t be surprised at all if the whole multithreading idea turns out to be a flop
...
Read the full article at 
http://www.informit.com/articles/article.aspx?p=1193856&amp;ns=15105</description>
		<content:encoded><![CDATA[<p>Interesting thread Dan &#8212; Knuth for one agrees with Dave Moon above.<br />
&#8230;.<br />
Donald: I don’t want to duck your question entirely. I might as well flame a bit about my personal unhappiness with the current trend toward multicore architecture. To me, it looks more or less like the hardware designers have run out of ideas, and that they’re trying to pass the blame for the future demise of Moore’s Law to the software writers by giving us machines that work faster only on a few key benchmarks! I won’t be surprised at all if the whole multithreading idea turns out to be a flop<br />
&#8230;<br />
Read the full article at<br />
<a href="http://www.informit.com/articles/article.aspx?p=1193856&amp;ns=15105" rel="nofollow">http://www.informit.com/articles/article.aspx?p=1193856&amp;ns=15105</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Weinreb</title>
		<link>http://danweinreb.org/blog/programming-with-concurrency/comment-page-1#comment-32290</link>
		<dc:creator>Dan Weinreb</dc:creator>
		<pubDate>Sun, 23 Aug 2009 09:11:31 +0000</pubDate>
		<guid isPermaLink="false">http://danweinreb.org/blog/?p=184#comment-32290</guid>
		<description>Rich, I don&#039;t understand what Dave Moon means by &quot;still need internal synchronization&quot;, either.  Perhaps he is talking about the level of abstraction below that seen by the programmer; but if so, I think that is beside the point. At the level of abstraction of the Clojure programmer, creation of a write-once data structure does not require any concurrency control to be done by the programmer.

The &quot;hardware cost of synchronizing&quot; isn&#039;t the problem being solved here. The problem being solved is bugs in programs that result from incorrect use of concurrency control mechanisms by programmers.  That is, the issue is correctness rather than performance.

When writing programs that have many threads operating in a shared space of memory/objects/whatever, experience has shown that unless the interactions between the threads can be kept very, very simple, it&#039;s easy to introduce bugs that are hard to understand and hard to debug, particularly because the bugs are hard to reproduce.  Various attempts to remedy this, such as the use of &quot;monitors&quot; or the Java &quot;synchronized&quot; construct, have not succeeded (at least in my opinion).

To the extent that a program can be written without the need for concurrency control at all, these problems obviously cannot occur. If there are only &quot;create&quot; and &quot;read&quot; operations with no &quot;update&quot; operations (and the only &quot;delete&quot; operations being done by a GC), no concurrency control need be coded.

When you do need concurrency control, the transaction concept is much easier to understand than locks or monitors.  It has very simple and clear invariants. This is why database management systems have been using transactions for such a long time, and why so many modern file systems use transactions now.

Now, it&#039;s a separate issue where fine-grained concurrency control is applicable.  The general idea is that if the way we&#039;re going to get more processing power is by having many concurrent processors (e.g. cores), there needs to be some way to keep all those cores busy. In the case of the subsystem that I currently spend my time working on, it&#039;s easy. We have a transaction processing system in which there are generally many concurrent requests.  We simply run separate threads (either sharing threads within processes, or putting each thread in its own process; it doesn&#039;t matter for purposes of this discussion), each thread handling a separate request.  So we don&#039;t need fine-grained concurrency control, for the most part.  However, there are other applications in which finer-grained concurrency control is a good, or even clearly the best, model.</description>
		<content:encoded><![CDATA[<p>Rich, I don&#8217;t understand what Dave Moon means by &#8220;still need internal synchronization&#8221;, either.  Perhaps he is talking about the level of abstraction below that seen by the programmer; but if so, I think that is beside the point. At the level of abstraction of the Clojure programmer, creation of a write-once data structure does not require any concurrency control to be done by the programmer.</p>
<p>The &#8220;hardware cost of synchronizing&#8221; isn&#8217;t the problem being solved here. The problem being solved is bugs in programs that result from incorrect use of concurrency control mechanisms by programmers.  That is, the issue is correctness rather than performance.</p>
<p>When writing programs that have many threads operating in a shared space of memory/objects/whatever, experience has shown that unless the interactions between the threads can be kept very, very simple, it&#8217;s easy to introduce bugs that are hard to understand and hard to debug, particularly because the bugs are hard to reproduce.  Various attempts to remedy this, such as the use of &#8220;monitors&#8221; or the Java &#8220;synchronized&#8221; construct, have not succeeded (at least in my opinion).</p>
<p>To the extent that a program can be written without the need for concurrency control at all, these problems obviously cannot occur. If there are only &#8220;create&#8221; and &#8220;read&#8221; operations with no &#8220;update&#8221; operations (and the only &#8220;delete&#8221; operations being done by a GC), no concurrency control need be coded.</p>
<p>When you do need concurrency control, the transaction concept is much easier to understand than locks or monitors.  It has very simple and clear invariants. This is why database management systems have been using transactions for such a long time, and why so many modern file systems use transactions now.</p>
<p>Now, it&#8217;s a separate issue where fine-grained concurrency control is applicable.  The general idea is that if the way we&#8217;re going to get more processing power is by having many concurrent processors (e.g. cores), there needs to be some way to keep all those cores busy. In the case of the subsystem that I currently spend my time working on, it&#8217;s easy. We have a transaction processing system in which there are generally many concurrent requests.  We simply run separate threads (either sharing threads within processes, or putting each thread in its own process; it doesn&#8217;t matter for purposes of this discussion), each thread handling a separate request.  So we don&#8217;t need fine-grained concurrency control, for the most part.  However, there are other applications in which finer-grained concurrency control is a good, or even clearly the best, model.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Weinreb</title>
		<link>http://danweinreb.org/blog/programming-with-concurrency/comment-page-1#comment-31576</link>
		<dc:creator>Dan Weinreb</dc:creator>
		<pubDate>Tue, 04 Aug 2009 10:13:19 +0000</pubDate>
		<guid isPermaLink="false">http://danweinreb.org/blog/?p=184#comment-31576</guid>
		<description>@Karl, I would love to go to JAOO but I don&#039;t think I can.</description>
		<content:encoded><![CDATA[<p>@Karl, I would love to go to JAOO but I don&#8217;t think I can.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karl Krukow</title>
		<link>http://danweinreb.org/blog/programming-with-concurrency/comment-page-1#comment-31548</link>
		<dc:creator>Karl Krukow</dc:creator>
		<pubDate>Mon, 03 Aug 2009 16:44:29 +0000</pubDate>
		<guid isPermaLink="false">http://danweinreb.org/blog/?p=184#comment-31548</guid>
		<description>I just wanted to let you know that Rich Hickey is coming to JAOO this year ;-) He is giving two talks: &quot;an introduction to Clojure&quot; and &quot;The Clojure Concurrency Model&quot;. I am particularly looking forward to the latter. Also, I will take the liberty and point out that you can get a 15% discount for JAOO registration:

http://blog.higher-order.net/2009/07/13/jaoo-discount/

Hope to see you there
/Karl</description>
		<content:encoded><![CDATA[<p>I just wanted to let you know that Rich Hickey is coming to JAOO this year <img src='http://danweinreb.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  He is giving two talks: &#8220;an introduction to Clojure&#8221; and &#8220;The Clojure Concurrency Model&#8221;. I am particularly looking forward to the latter. Also, I will take the liberty and point out that you can get a 15% discount for JAOO registration:</p>
<p><a href="http://blog.higher-order.net/2009/07/13/jaoo-discount/" rel="nofollow">http://blog.higher-order.net/2009/07/13/jaoo-discount/</a></p>
<p>Hope to see you there<br />
/Karl</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rascunho &#187; Blog Archive &#187; links for 2009-07-27</title>
		<link>http://danweinreb.org/blog/programming-with-concurrency/comment-page-1#comment-31456</link>
		<dc:creator>rascunho &#187; Blog Archive &#187; links for 2009-07-27</dc:creator>
		<pubDate>Fri, 31 Jul 2009 20:18:19 +0000</pubDate>
		<guid isPermaLink="false">http://danweinreb.org/blog/?p=184#comment-31456</guid>
		<description>[...] Dan Weinreb’s blog » Blog Archive » Programming with Concurrency If you might have to write highly-concurrent programs in the future, I recommend that you keep your eyes on all this. (tags: danweinreb.org 2009 mes6 dia27 programming concurrency blog_post clojure trends *****) [...]</description>
		<content:encoded><![CDATA[<p>[...] Dan Weinreb’s blog » Blog Archive » Programming with Concurrency If you might have to write highly-concurrent programs in the future, I recommend that you keep your eyes on all this. (tags: danweinreb.org 2009 mes6 dia27 programming concurrency blog_post clojure trends *****) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rich Hickey</title>
		<link>http://danweinreb.org/blog/programming-with-concurrency/comment-page-1#comment-31446</link>
		<dc:creator>Rich Hickey</dc:creator>
		<pubDate>Fri, 31 Jul 2009 14:59:41 +0000</pubDate>
		<guid isPermaLink="false">http://danweinreb.org/blog/?p=184#comment-31446</guid>
		<description>Hmm, I find myself disagreeing with Dave Moon, so I&#039;ve probably misunderstood.

For Clojure&#039;s data structures, normal one-time initialization is of newly created objects in a single thread, so there is no other thread with which to synchronize. Thus I&#039;m confused by &quot;still need internal synchronization&quot;. Even in the specialized parallel construction scenarios (e.g. parallel map on vectors), each sub-component of the data structure is allocated and written to by only a single thread and never written once published, so while there is workflow synchronization of course, there is none for the data itself. When you share an &#039;immutable&#039; data structure with another thread, the memory will need to be made visible to the processor running that thread, but it being &#039;read-only&#039; means that can be done so in the least cost way, and subsequent reads can be free of all but the most minimal memory coherence protocols. 

Perhaps we are dealing with different notions of synchronization, but often when talking about synchronization required for shared mutable memory we are talking about higher-level, higher cost things like CAS or locks. Neither of these is needed at any point (internally or externally) for the create-and-publish approach used in Clojure&#039;s data structures. The lack of need for any higher-level synchronization for subsequent multithreaded reading is a big difference vs correctly reading any potentially mutable data structure.

The fact that these persistent data structures end up being trees of immutable nodes yields many benefits, one being pervasive structural sharing. This means that making a copy for single-threaded or partitioned parallel multithreaded &quot;mutation&quot; is O(1). &#039;Mutation&#039; creates newly allocated nodes, but can share freely with the source in the sparse case. When done, making the result immutable and persistent is also O(1). Even on modest (quad-core) hardware, a parallel implementation of map, when worst-case fully replacing, trounces a single threaded mutation in place using a mutable data structure, the latter having no sharing story other than &quot;good luck with that&quot;. 

Contrast this with any scheme for “single thread w/’private’ mutable memory”, given any sharing (and if there is no sharing there is no interesting problem, they are separate programs, or, functional spawn). You must serialize access, via ownership handoff (see &lt;a href=&quot;http://www.malhar.net/sriram/kilim/&quot; rel=&quot;nofollow&quot;&gt;Kilim&lt;/a&gt;), message queue (Erlang), or, at least, lock-while-copy. And a critical point in the last case is that if you ever share it, however infrequently, your in-owner-thread code will have to use synchronization constructs. The communication objects in all cases other than handoff are usually immutable anyway, so why not use them all the time if not prohibitive otherwise?

Most important though, is that programming with &quot;values&quot; is vastly simpler than programming with memory. It may not currently be faster, but as the core counts climb it is likely to become so. I&#039;m keeping my money on allocate -&gt; initialize -&gt; publish-immutably.

As I finish this I&#039;m realizing you probably were only talking about the costs of making memory visible to more than one core. Oh well, I&#039;ve written the rant already :) 

I agree that thread/core/memory compartmentalization is going to become interesting and look forward to having the constructs to manage it. One language that formalizes the notion of &#039;place&#039; is &lt;a href=&quot;http://x10.codehaus.org/&quot; rel=&quot;nofollow&quot;&gt;IBM&#039;s X10&lt;/a&gt; [2], although IIRC, an SMP is only a single place, the target being clustered HPC.
</description>
		<content:encoded><![CDATA[<p>Hmm, I find myself disagreeing with Dave Moon, so I&#8217;ve probably misunderstood.</p>
<p>For Clojure&#8217;s data structures, normal one-time initialization is of newly created objects in a single thread, so there is no other thread with which to synchronize. Thus I&#8217;m confused by &#8220;still need internal synchronization&#8221;. Even in the specialized parallel construction scenarios (e.g. parallel map on vectors), each sub-component of the data structure is allocated and written to by only a single thread and never written once published, so while there is workflow synchronization of course, there is none for the data itself. When you share an &#8216;immutable&#8217; data structure with another thread, the memory will need to be made visible to the processor running that thread, but it being &#8216;read-only&#8217; means that can be done so in the least cost way, and subsequent reads can be free of all but the most minimal memory coherence protocols. </p>
<p>Perhaps we are dealing with different notions of synchronization, but often when talking about synchronization required for shared mutable memory we are talking about higher-level, higher cost things like CAS or locks. Neither of these is needed at any point (internally or externally) for the create-and-publish approach used in Clojure&#8217;s data structures. The lack of need for any higher-level synchronization for subsequent multithreaded reading is a big difference vs correctly reading any potentially mutable data structure.</p>
<p>The fact that these persistent data structures end up being trees of immutable nodes yields many benefits, one being pervasive structural sharing. This means that making a copy for single-threaded or partitioned parallel multithreaded &#8220;mutation&#8221; is O(1). &#8216;Mutation&#8217; creates newly allocated nodes, but can share freely with the source in the sparse case. When done, making the result immutable and persistent is also O(1). Even on modest (quad-core) hardware, a parallel implementation of map, when worst-case fully replacing, trounces a single threaded mutation in place using a mutable data structure, the latter having no sharing story other than &#8220;good luck with that&#8221;. </p>
<p>Contrast this with any scheme for “single thread w/’private’ mutable memory”, given any sharing (and if there is no sharing there is no interesting problem, they are separate programs, or, functional spawn). You must serialize access, via ownership handoff (see <a href="http://www.malhar.net/sriram/kilim/" rel="nofollow">Kilim</a>), message queue (Erlang), or, at least, lock-while-copy. And a critical point in the last case is that if you ever share it, however infrequently, your in-owner-thread code will have to use synchronization constructs. The communication objects in all cases other than handoff are usually immutable anyway, so why not use them all the time if not prohibitive otherwise?</p>
<p>Most important though, is that programming with &#8220;values&#8221; is vastly simpler than programming with memory. It may not currently be faster, but as the core counts climb it is likely to become so. I&#8217;m keeping my money on allocate -&gt; initialize -&gt; publish-immutably.</p>
<p>As I finish this I&#8217;m realizing you probably were only talking about the costs of making memory visible to more than one core. Oh well, I&#8217;ve written the rant already <img src='http://danweinreb.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<p>I agree that thread/core/memory compartmentalization is going to become interesting and look forward to having the constructs to manage it. One language that formalizes the notion of &#8216;place&#8217; is <a href="http://x10.codehaus.org/" rel="nofollow">IBM&#8217;s X10</a> [2], although IIRC, an SMP is only a single place, the target being clustered HPC.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
