<?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>The problem with being second</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx</link><description>First, hats off to the Mono team . I think they've done a great job at writing some great software, but also at proving that evil MS really does know how to produce a truly common language runtime that can be properly standardized and ported to other</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: The problem with being second</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#226362</link><pubDate>Tue, 07 Sep 2004 17:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:226362</guid><dc:creator>Jim Arnold</dc:creator><description>Er, what's the point in having a portable runtime if I have to make my high-level code aware of the processor I'm running on?  Are you saying that the behaviour of my code varies between x86 and AMD64?</description></item><item><title>re: The problem with being second</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#226364</link><pubDate>Tue, 07 Sep 2004 17:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:226364</guid><dc:creator>Grant</dc:creator><description>No you shouldn't have to be aware of the processor you're running on, but yes, there will be differences.  And specifically if you're writing multi-threaded code and you don't follow the spec for all the things the runtime is allowed to do (but may not actually be doing right now on x86 version 1.0 or 1.1) you will likely get bitten.&lt;br&gt;&lt;br&gt;My point is that that x86 is allowed to do the same thing, but they don't (right now). It is tough being second because people find these differences and naturally assume it's a bug in the new stuff, rather than their own mis-use or misunderstanding.&lt;br&gt;--Grant</description></item><item><title>re: The problem with being second</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#226371</link><pubDate>Tue, 07 Sep 2004 17:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:226371</guid><dc:creator>Joe</dc:creator><description>I agree, hats off to the Mono team, but suspect that over time it will be difficult to keep up with the evolution of the .NET Framework.  And a minimal CLR won't be enough for many users - .NET 2.0 contains lots of stuff which will quickly become &amp;quot;must have&amp;quot;.  &lt;br&gt;&lt;br&gt;I remember people taking their hats off to IBM when OS/2 was a &amp;quot;better Windows than Windows&amp;quot;.   But IBM couldn't keep up with the evolution to Win32.&lt;br&gt;&lt;br&gt;I already know of one subtle difference which could mean an app that runs in Mono might break in MS .NET. </description></item><item><title>re: The problem with being second</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#226372</link><pubDate>Tue, 07 Sep 2004 17:33:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:226372</guid><dc:creator>Barry Dorrans</dc:creator><description>What about the spot CLR, or the compact CLR?&lt;br&gt;&lt;br&gt;Aren't you fourth? :)</description></item><item><title>re: The problem with being second</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#226376</link><pubDate>Tue, 07 Sep 2004 17:39:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:226376</guid><dc:creator>Grant</dc:creator><description>I've never heard of the spot CLR.&lt;br&gt;&lt;br&gt;In the case of the compact CLR, they weren't trying to duplicate the desktop CLR, but simply mimic it.  Thus certain differences were expected.  Also due to device constraints the compact CLR is unlikely to perform more optimizations than the desktop CLR.&lt;br&gt;&lt;br&gt;People expect the desktop CLR and compact CLR to be slightly different.  People won't expect the CLR to be different between their server running on a Xeon and their server running on an Opteron.&lt;br&gt;&lt;br&gt;Yes, technically you are right about us not being the second JIT (there was even the Rotor JITs).  But we are the second desktop JIT built by Microsoft that was expected to perform as good as the existing JIT, but on a new architecture.&lt;br&gt;--Grant</description></item><item><title>re: The problem with being second</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#226381</link><pubDate>Tue, 07 Sep 2004 17:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:226381</guid><dc:creator>Barry Dorrans</dc:creator><description>Ah, the Spot CLR is the never confirmed but widely rumoured CLR for the Spot watches.&lt;br&gt;&lt;br&gt;So is there an Intel 64bit CLR out there as well?&lt;br&gt;&lt;br&gt;Is the AMD64 CLR tied to XP-64bit, or will it be optimising in a 32 bit environment?</description></item><item><title>re: The problem with being second</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#226383</link><pubDate>Tue, 07 Sep 2004 17:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:226383</guid><dc:creator>Grant</dc:creator><description>Yes, the AMD64 JIT will support the Intel processors that implement the x64 extensions, as well as the Itanium family.  These 64-bit JITs will only work on a 64-bit CLR on a 64-bit OS (Windows Server 2003 for x64 is in beta IIRC).&lt;br&gt;&lt;br&gt;Also don't get me wrong, the x86 JIT is working on a fair number of their own optimizations to speed things up.&lt;br&gt;--Grant</description></item><item><title>re: The problem with being second</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#226393</link><pubDate>Tue, 07 Sep 2004 18:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:226393</guid><dc:creator>anonymous </dc:creator><description>Top wish for this JIT (and the next version of the 32-bit one): &lt;br&gt;Allow inlining of functions that operate on value types. 3D vector math would be soo much faster and more convienent if you could use a vector class without worrying that every little vec3+vec3 will turn into a full function call..</description></item><item><title>re: The problem with being second</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#226397</link><pubDate>Tue, 07 Sep 2004 18:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:226397</guid><dc:creator>Craig Thrall</dc:creator><description>Here's a question for you. If the spec allows both behaviors, does that indicate a problem in the spec that should be revisited? Make a change to specifically say &amp;quot;local references will change across threads?&amp;quot;</description></item><item><title>re: The problem with being second</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#226401</link><pubDate>Tue, 07 Sep 2004 18:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:226401</guid><dc:creator>Grant</dc:creator><description>That not what's happening.  Look at the spec for the C# keyword volatile or the volatile IL opcode prefix.  Unless those are present the JIT/runtime is free to assume that only 1 thread is modifying the variable at a time, and therefore can perform agressive optimizations that make your app run faster (like putting things in registers).  That's all in the spec.  The problem is that most people don't read the spec, they just try it and see if it works. :(&lt;br&gt;--Grant</description></item><item><title>re: The problem with being second</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#226416</link><pubDate>Tue, 07 Sep 2004 19:16:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:226416</guid><dc:creator>Jeroen Frijters</dc:creator><description>I can't for the life of me figure out why you think this optimization is legal.&lt;br&gt;&lt;br&gt;If I understand you correctly, you are effectively saying the contents of a local variable can be affected by another thread, right? But when Craig said this you reply that that is not the case, but your explanation of volatile is totally incorrect. Volatile loads/stores act as a memory barrier, but that's basically irrelevant here, we're looking at the behavior of a single thread and your optimization clearly violates the spec:&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&lt;br&gt;Conforming implementations of the CLI are free to execute programs using any technology that guarantees, within a single thread of execution, that side-effects and exceptions generated by a thread are visible in the order specified by the CIL.&lt;br&gt;&amp;lt;&amp;lt;&amp;lt;&lt;br&gt;</description></item><item><title>re: The problem with being second</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#226428</link><pubDate>Tue, 07 Sep 2004 19:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:226428</guid><dc:creator>Grant</dc:creator><description>OK. Show me how replacing all occurances of the local 'lbuckets' with the member variable 'buckets' violates that statement.  The replacement will not change the order of exceptions, nor any of the side-effects on a *single* thread.&lt;br&gt;&lt;br&gt;On multple threads, yes the side-effects definitely change, but the spec is clear about only applying to a single thread.&lt;br&gt;&lt;br&gt;You are correct about volatile acting as memory barriers.  That basically means that reading and writing suddenly become side-effects.  The original code has only one read of the member variable 'buckets'.  If it was a volatile read, the JIT would be forced to only have one read and thus force the JIT to use that read to copy into a non-volatile local (as the user intended).  If it didn't and instead tried to replace all occurances of 'lbuckets' with 'buckets' it would be violating the rule because now there are more memory barriers.  Hence the need for volatile.&lt;br&gt;--Grant</description></item><item><title>re: The problem with being second</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#226593</link><pubDate>Wed, 08 Sep 2004 02:14:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:226593</guid><dc:creator>Ryan Lamansky (Kardax)</dc:creator><description>&amp;quot;To a amateur, if it works, it's right.  To a professional, if it's right, it works&amp;quot;.&lt;br&gt;&lt;br&gt;I welcome any new optimizations, even if they happen to break someone's buggy code.</description></item><item><title>re: The problem with being second</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#226834</link><pubDate>Wed, 08 Sep 2004 15:11:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:226834</guid><dc:creator>Dmitriy Zaslavskiy</dc:creator><description>I just hope when MS guys will realize how much code is broken by those optimization they won't simply remove it, but rather make it an opt-in atrribute. Maybe add another flag to CompilationRelaxations</description></item><item><title>re: The problem with being second</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#227306</link><pubDate>Thu, 09 Sep 2004 11:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:227306</guid><dc:creator>Ryan Lamansky (Kardax)</dc:creator><description>I gave this some thought, and I really don't think very much code would be broken.  Relatively few .NET applications use threading, and those that do invariably do it to improve the speed or responsiveness of their program... any optimizations would be good news.&lt;br&gt;&lt;br&gt;Not to mention, we're talking about a Major New Release--this is 2.0 coming up, not 1.2.  This is the time for riskier changes.&lt;br&gt;&lt;br&gt;CompilationRelaxations is worth considering, but I don't think using it to support the small amount of flawed code affected by this issue is the right direction.</description></item><item><title>re: The problem with being second</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#227334</link><pubDate>Thu, 09 Sep 2004 13:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:227334</guid><dc:creator>Jeroen Frijters</dc:creator><description>I disagree with your (and apparently most of the CLR team's) reading of the spec (and even if I'd agree, I'd say the spec is broken), but let's assume for a moment that I agree with your reading, in that case the only place where things can go wrong is the &amp;quot;lbuckets.Length&amp;quot; that is passed into the InitHash method. The subsequent ones that you highlighted are not allowed to be read from the field, because InitHash contains a virtual method call to GetHash and that effectively prevents the JIT from seeing if anyone else on this thread is going to write to the buckets field.</description></item><item><title>Some Clarifications</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#230118</link><pubDate>Wed, 15 Sep 2004 23:32:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:230118</guid><dc:creator>GrantRi's WebLog [MS]</dc:creator><description /></item><item><title>Safely firing an event, Part 3</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#230683</link><pubDate>Fri, 17 Sep 2004 02:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:230683</guid><dc:creator>jaybaz [MS] WebLog</dc:creator><description /></item><item><title>re: The problem with being second</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#230699</link><pubDate>Fri, 17 Sep 2004 00:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:230699</guid><dc:creator>Matthew W. Jackson</dc:creator><description>Is this really an issue in this case?  I thought that Hashtables weren't intended to be thread-safe, and if you're using them in two threads and are modifying the data, it's up to the caller to use monitors or other synchronization techniques.  If one thread calls Add and another calls ContainsKey without locking, that's not the fault of the code or the JIT, is it?</description></item><item><title>Volatile reads and writes in VB</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#236288</link><pubDate>Thu, 30 Sep 2004 22:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:236288</guid><dc:creator>Panopticon Central</dc:creator><description>How to be more volatile.</description></item><item><title>re: Good post on running/writing/compiling managed binaries as 32-bit or 64-bit</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#244098</link><pubDate>Mon, 18 Oct 2004 22:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:244098</guid><dc:creator>GrantRi's WebLog [MS]</dc:creator><description /></item><item><title>re: Field access versus local variable access performance</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#268060</link><pubDate>Mon, 22 Nov 2004 21:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:268060</guid><dc:creator>Wintellog</dc:creator><description /></item><item><title>Volatile reads and writes in VB</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#442792</link><pubDate>Mon, 25 Jul 2005 02:17:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:442792</guid><dc:creator>Panopticon Central</dc:creator><description>How to be more volatile.</description></item><item><title>Volatile reads and writes in VB</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#443747</link><pubDate>Wed, 27 Jul 2005 09:34:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:443747</guid><dc:creator>Panopticon Central</dc:creator><description>How to be more volatile.</description></item><item><title>The CLI memory model, and specific specifications</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#1155175</link><pubDate>Mon, 27 Nov 2006 00:49:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1155175</guid><dc:creator>Jon Skeet's Coding Blog</dc:creator><description>&lt;p&gt;A while ago, I was directed to a disturbing (in my view) post on GrantRi's blog, to do with the .NET&lt;/p&gt;
</description></item><item><title>Actors and Actresses  &amp;raquo; Archive du blog   &amp;raquo; GrantRi&amp;#8217;s WebLog [MS] : The problem with being second</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#6983469</link><pubDate>Sat, 05 Jan 2008 00:25:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6983469</guid><dc:creator>Actors and Actresses  » Archive du blog   » GrantRi’s WebLog [MS] : The problem with being second</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://actors.247blogging.info/?p=4352"&gt;http://actors.247blogging.info/?p=4352&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>Famous Quotes &amp;raquo; GrantRi&amp;#8217;s WebLog [MS] : Good post on running/writing/compiling managed &amp;#8230;</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#6990151</link><pubDate>Sat, 05 Jan 2008 13:46:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6990151</guid><dc:creator>Famous Quotes » GrantRi’s WebLog [MS] : Good post on running/writing/compiling managed …</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://famousquotes.247blogging.info/?p=1131"&gt;http://famousquotes.247blogging.info/?p=1131&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>Dinner and a Movie &amp;raquo; GrantRi&amp;#8217;s WebLog [MS] : The problem with being second</title><link>http://blogs.msdn.com/grantri/archive/2004/09/07/226355.aspx#8327888</link><pubDate>Thu, 20 Mar 2008 23:38:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8327888</guid><dc:creator>Dinner and a Movie » GrantRi’s WebLog [MS] : The problem with being second</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://dinnermoviesblog.info/grantris-weblog-ms-the-problem-with-being-second/"&gt;http://dinnermoviesblog.info/grantris-weblog-ms-the-problem-with-being-second/&lt;/a&gt;&lt;/p&gt;</description></item></channel></rss>