<?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>More Performance Tidbits for library writers</title><link>http://blogs.msdn.com/ricom/archive/2004/10/25/247423.aspx</link><description>However careful you are with your performance culture when creating everyday professional code you need to be doubly careful when creating libraries for other developers. This is of course because when writing a library you can't know in advance exactly</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: More Performance Tidbits for library writers</title><link>http://blogs.msdn.com/ricom/archive/2004/10/25/247423.aspx#247458</link><pubDate>Mon, 25 Oct 2004 22:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:247458</guid><dc:creator>Andreas Wölfer</dc:creator><description>Rico - thank you for that. Glad i was listening :)</description></item><item><title>re: More Performance Tidbits for library writers</title><link>http://blogs.msdn.com/ricom/archive/2004/10/25/247423.aspx#247615</link><pubDate>Mon, 25 Oct 2004 23:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:247615</guid><dc:creator>Rico Mariani</dc:creator><description>Doh, it's Principle not Principal -- I noticed that when I first sent this out as email and then I didn't fix it when I posted it as a blog... &lt;br&gt;&lt;br&gt;Thanks readers :)</description></item><item><title>The Seven (of n) Principles of Highly Effective Programmers</title><link>http://blogs.msdn.com/ricom/archive/2004/10/25/247423.aspx#247764</link><pubDate>Tue, 26 Oct 2004 09:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:247764</guid><dc:creator>Zupancic Perspective</dc:creator><description /></item><item><title>re: More Performance Tidbits for library writers</title><link>http://blogs.msdn.com/ricom/archive/2004/10/25/247423.aspx#247814</link><pubDate>Tue, 26 Oct 2004 10:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:247814</guid><dc:creator>Stu Smith</dc:creator><description>Regarding point 5, it's a shame the compiler and BCL couldn't work together to handle this. Using foreach seems to me to be the natural way of iterating any array or collection, but it has this performance hit. ArrayList (for example) is virtual, yet I would have thought most people use it as-is. Perhaps if ArrayList had been ArrayListBase (abstract but with no abstract methods), with a sealed ArrayList derived from it, then the various compilers could have recognised that, and emitted an IL for-loop instead of a foreach. And surely arrays could be compiled in this way as the framework stands?</description></item><item><title>re: More Performance Tidbits for library writers</title><link>http://blogs.msdn.com/ricom/archive/2004/10/25/247423.aspx#247883</link><pubDate>Tue, 26 Oct 2004 14:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:247883</guid><dc:creator>Rico Mariani</dc:creator><description>List&amp;lt;T&amp;gt; doesn't have this problem so hopefully people will be happy with List&amp;lt;Object&amp;gt; anywhere they would have used ArrayList going forward.&lt;br&gt;&lt;br&gt;</description></item><item><title>re: More Performance Tidbits for library writers</title><link>http://blogs.msdn.com/ricom/archive/2004/10/25/247423.aspx#248066</link><pubDate>Tue, 26 Oct 2004 19:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:248066</guid><dc:creator>Omer van Kloeten</dc:creator><description>I'm with Stu on this. I actually wanted to say it myself, but Stu put it very well.&lt;br&gt;I think that the compiler could do a very nice job recognizing the BCL's collections. Since these collections have the overhead during foreach, but not during for, it could compile foreaches to fors.&lt;br&gt;&lt;br&gt;You're saying &amp;quot;it'll be fixed for version 2.0&amp;quot;, but we need it inside systems that are already in production with v1.1. Can something be done about this?&lt;br&gt;&lt;br&gt;Also, could you elaborate on the &amp;quot;List&amp;lt;T&amp;gt; doesn't have this problem&amp;quot; bit?</description></item><item><title>re: More Performance Tidbits for library writers</title><link>http://blogs.msdn.com/ricom/archive/2004/10/25/247423.aspx#248074</link><pubDate>Tue, 26 Oct 2004 20:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:248074</guid><dc:creator>Rico Mariani</dc:creator><description>Quoting myself from the Performance and Scalability PAG&lt;br&gt;&lt;br&gt;Enumeration Overhead&lt;br&gt;&lt;br&gt;The .NET Framework version 1.1 collections provide an enumerator by overriding IEnumerable.GetEnumerator. This turns out to be less than optimal for a number of reasons: &lt;br&gt;&lt;br&gt;-The GetEnumerator method is virtual, so the call cannot be inlined. &lt;br&gt;&lt;br&gt;-The return value is an IEnumerator interface instead of an exact type; as a result, the exact enumerator cannot be known at compile time. &lt;br&gt;&lt;br&gt;-The MoveNext method and Current properties are again virtual and so cannot be inlined. &lt;br&gt;IEnumerator.Current requires a return type of System.Object, rather than a more specific data type which may require boxing and unboxing, depending on the data types stored in the collection. &lt;br&gt;&lt;br&gt;As a result of these factors, there are both managed heap and virtual function overhead associated with foreach on simple collection types. This can be a significant factor in performance-sensitive regions of your application.&lt;br&gt;&lt;br&gt;For information about how to minimize the overhead, see &amp;quot;Consider Enumerating Overhead&amp;quot; &lt;br&gt;&lt;br&gt;The relevant section is:&lt;br&gt;&lt;br&gt;&lt;a target="_new" href="http://msdn.microsoft.com/library/en-us/dnpag/html/scalenetchapt05.asp?frame=true#scalenetchapt05_topic25"&gt;http://msdn.microsoft.com/library/en-us/dnpag/html/scalenetchapt05.asp?frame=true#scalenetchapt05_topic25&lt;/a&gt;&lt;br&gt;&lt;br&gt;These problems were all fixed in List&amp;lt;T&amp;gt; -- sadly we we're stuck with it in ArrayList because we'd have to break existing applications to fix it.</description></item><item><title>New </title><link>http://blogs.msdn.com/ricom/archive/2004/10/25/247423.aspx#248283</link><pubDate>Wed, 27 Oct 2004 04:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:248283</guid><dc:creator>OdeToCode Link Blog</dc:creator><description /></item><item><title>Amping up .NET performance</title><link>http://blogs.msdn.com/ricom/archive/2004/10/25/247423.aspx#248384</link><pubDate>Wed, 27 Oct 2004 09:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:248384</guid><dc:creator>TrackBack</dc:creator><description>&lt;br&gt;Weblogs.asp.net had a cool link to Rico Mariani's weblog that has a lot of good posts about tuning the most out of .NET applications. Some of the tips are pretty generic and can be applied to other programming languages and platforms as well.  Specif</description></item><item><title>Performance Tidbits for Library writers</title><link>http://blogs.msdn.com/ricom/archive/2004/10/25/247423.aspx#248408</link><pubDate>Wed, 27 Oct 2004 11:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:248408</guid><dc:creator>Martin's WebLog</dc:creator><description /></item><item><title>Performance tips for library writers</title><link>http://blogs.msdn.com/ricom/archive/2004/10/25/247423.aspx#248414</link><pubDate>Wed, 27 Oct 2004 12:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:248414</guid><dc:creator>Tiago Pascoal's WebLog</dc:creator><description /></item><item><title>re: More Performance Tidbits for library writers</title><link>http://blogs.msdn.com/ricom/archive/2004/10/25/247423.aspx#248545</link><pubDate>Wed, 27 Oct 2004 16:16:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:248545</guid><dc:creator>Joe</dc:creator><description>Isn't foreach on an array (not an arraylist, a real array) optimized already by the compiler?  In fact it should be faster than using indexes because there won't be an around bounds check (which can happen for anything that the simplisting index based iteration).</description></item><item><title>re: More Performance Tidbits for library writers</title><link>http://blogs.msdn.com/ricom/archive/2004/10/25/247423.aspx#248559</link><pubDate>Wed, 27 Oct 2004 16:36:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:248559</guid><dc:creator>Rico Mariani</dc:creator><description>Foreach on regular arrays gives you the best code.  &amp;quot;For&amp;quot; on arrays often has no bounds check either if it's coded in one of the obvious safe ways.</description></item><item><title>Readings for 10.27.2004</title><link>http://blogs.msdn.com/ricom/archive/2004/10/25/247423.aspx#248599</link><pubDate>Wed, 27 Oct 2004 20:34:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:248599</guid><dc:creator>The Diffracted Developer</dc:creator><description /></item><item><title>Readings for 10.27.2004</title><link>http://blogs.msdn.com/ricom/archive/2004/10/25/247423.aspx#248782</link><pubDate>Thu, 28 Oct 2004 01:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:248782</guid><dc:creator>The Diffracted Developer</dc:creator><description /></item><item><title>re: More Performance Tidbits for library writers</title><link>http://blogs.msdn.com/ricom/archive/2004/10/25/247423.aspx#249407</link><pubDate>Fri, 29 Oct 2004 04:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:249407</guid><dc:creator>Dmitriy Zaslavskiy</dc:creator><description>Rico could explain why does LinkedListNode stores back reference to LinkedList?&lt;br&gt;I am not asking why in term of implementation but rather in term of library design?&lt;br&gt;Why pay an extra pointer for each element.&lt;br&gt;&lt;br&gt;In fact I would argue that a lot of the time people know that the objects they want to keep will go into this or that collection. Therefore they might be willing to derive from LinkedListNode to save on extra 12 bytes (+ allocations). Or maybe just to implement interface ILinkedNode ?</description></item><item><title>More Performance Tidbits for library writers</title><link>http://blogs.msdn.com/ricom/archive/2004/10/25/247423.aspx#249546</link><pubDate>Fri, 29 Oct 2004 16:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:249546</guid><dc:creator>dotRob</dc:creator><description /></item><item><title>I think I got it now</title><link>http://blogs.msdn.com/ricom/archive/2004/10/25/247423.aspx#249551</link><pubDate>Fri, 29 Oct 2004 16:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:249551</guid><dc:creator>dotRob</dc:creator><description /></item><item><title>More Performance Tidbits for library writers</title><link>http://blogs.msdn.com/ricom/archive/2004/10/25/247423.aspx#250065</link><pubDate>Sat, 30 Oct 2004 23:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:250065</guid><dc:creator>dotRob</dc:creator><description /></item><item><title>re: More Performance Tidbits for library writers</title><link>http://blogs.msdn.com/ricom/archive/2004/10/25/247423.aspx#250986</link><pubDate>Tue, 02 Nov 2004 08:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:250986</guid><dc:creator>Arun Philip</dc:creator><description>Wow! Great points.</description></item><item><title>re: More Performance Tidbits for library writers</title><link>http://blogs.msdn.com/ricom/archive/2004/10/25/247423.aspx#251093</link><pubDate>Tue, 02 Nov 2004 14:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:251093</guid><dc:creator>Rico Mariani</dc:creator><description>I'd like to remind folks of an important truth...&lt;br&gt;&lt;br&gt;I only have two rules &lt;br&gt;&lt;br&gt;#1 Measure &lt;br&gt;#2 Do your homework &lt;br&gt;&lt;br&gt;&amp;quot;Don't use foreach&amp;quot; isn't in the list. &lt;br&gt;&lt;br&gt;Better advice would be &amp;quot;foreach is good for everything but ArrayList&amp;quot; but even that isn't quite right... &lt;br&gt;&lt;br&gt;#1 and #2 imply an important corollary --&amp;quot;Don't use pithy advice from so called experts (such as me) instead of doing your own measurements&amp;quot; </description></item><item><title>re: More Performance Tidbits for library writers</title><link>http://blogs.msdn.com/ricom/archive/2004/10/25/247423.aspx#257600</link><pubDate>Mon, 15 Nov 2004 16:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:257600</guid><dc:creator>Ovidiu</dc:creator><description>As usual, a great post :) As for the &amp;quot;pretend that following a pointer is a very costly operation&amp;quot; part, I think the best picture one can get is by the following comparison:&lt;br&gt;&lt;br&gt;&amp;lt;&amp;lt;Now 2GHz is a difficult thing to imagine for a human. Put simply that is 2 billion (Dr Evil pose) instructions per second at maximum throughput. So lets put this on our terms. Let's say once processor “clock cycle” is not 1/2,000,000,000 of a second but rather 1 second. On that scale accessing the nearby L1 on-chip cache takes 6 seconds, the off chip (L2) cache 2-3 minutes, and accessing main memory takes 3-4 weeks. Accessing the disk (just one disk access) by comparison takes a whopping 1 year on this timescale.&amp;gt;&amp;gt;&lt;br&gt;&lt;br&gt;(From &lt;a target="_new" href="http://weblogs.asp.net/simonme/archive/2004/05/31/145024.aspx"&gt;http://weblogs.asp.net/simonme/archive/2004/05/31/145024.aspx&lt;/a&gt;)</description></item></channel></rss>