<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Rico Mariani's Performance Tidbits</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/ricom/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/ricom/feed.xml</link>
    <description>Implying no warranties and conferring no rights: &amp;quot;AS IS&amp;quot; since 1988</description>
    <lastBuildDate>Mon, 22 May 2017 11:32:41 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Forwarding address</title>
      <link>https://docs.microsoft.com/archive/blogs/ricom/forwarding-address</link>
      <pubDate>Mon, 22 May 2017 11:31:01 GMT</pubDate>
      <dc:creator><![CDATA[ricom]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ricom/?p=3016</guid>
      <description><![CDATA[You can find me posting here now:

https://www.facebook.com/perftidbits]]></description>
      <content:encoded><![CDATA[You can find me posting here now:

<a href="https://www.facebook.com/perftidbits">https://www.facebook.com/perftidbits</a>]]></content:encoded>
    </item>
    <item>
      <title>Final Posting</title>
      <link>https://docs.microsoft.com/archive/blogs/ricom/final-posting</link>
      <pubDate>Thu, 23 Mar 2017 20:54:02 GMT</pubDate>
      <dc:creator><![CDATA[ricom]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ricom/?p=3015</guid>
      <description><![CDATA[My last day at Microsoft will be tomorrow, 3/24/2017.  

I really did want to get to some of the...]]></description>
      <content:encoded><![CDATA[My last day at Microsoft will be tomorrow, 3/24/2017.  

I really did want to get to some of the old comments that had been neglected but alas, there's no time.   

I'm not sure I will actually lose access to this blog because of the way authorization happens but I think it would be a bad idea for me to keep using it because of its strong affiliation with MS.

Best wishes to all and thanks for reading all these years.

-Rico

@ricomariani]]></content:encoded>
    </item>
    <item>
      <title>Discovered comments</title>
      <link>https://docs.microsoft.com/archive/blogs/ricom/discovered-comments</link>
      <pubDate>Fri, 03 Feb 2017 09:47:46 GMT</pubDate>
      <dc:creator><![CDATA[ricom]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ricom/?p=3005</guid>
      <description><![CDATA[I just discovered that there are all kinds of comments pending approval, some from several months...]]></description>
      <content:encoded><![CDATA[I just discovered that there are all kinds of comments pending approval, some from several months ago.  Not something I was used to on the old platform.  

So apologies for not responding to those comments sooner, I got too used to the old system.  Traditionally I've not censored any comments and I'll try to do the same with these.  Although one was an outright flame so there's no point in that... but look for them in the next few days.  If you see something of yours pop up, please forgive me, I didn't mean to censor anything.  It was just pilot error.

And, big surprise, most of the comments are people who think I've lost my mind about 64 bit processor benefits.

Maybe they're right?]]></content:encoded>
    </item>
    <item>
      <title>symbol filter redux</title>
      <link>https://docs.microsoft.com/archive/blogs/ricom/symbol-filter-redux</link>
      <pubDate>Fri, 03 Feb 2017 02:05:07 GMT</pubDate>
      <dc:creator><![CDATA[ricom]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ricom/?p=2985</guid>
      <description><![CDATA[A while ago I provided this local symbol server proxy you could use to get just the symbols you...]]></description>
      <content:encoded><![CDATA[<div>

A while ago I provided this local symbol server proxy you could use to get just the symbols you want.  I was watching it work a couple of weeks ago and I noticed that most of the time what it ends up doing is proxying a 302 redirect.  Which was kind of cool because that meant that it didn't actually have to do much heavy lifting at all and the symbols were coming directly from the original source.  That's when it hit me that I had been doing it wrong the whole time.  So I deleted all the of the proxy code.  What it does now is that it always serves either a 404 if the request isn't on the white-list or it serves a 302 if it is on the white list.  It just redirects according to the path provided.

The original article is <a href="https://blogs.msdn.microsoft.com/ricom/2014/12/08/use-symbol-filtering-to-get-symbols-you-care-about-from-your-server-instead-of-getting-the-kitchen-sink/">here</a>
</div>
<div></div>
<div>To use it, instead of doing this:</div>

<br />
<div>set _NT_SYMBOL_PATH=srv*http://yourserver/yourpath</div>
<br />
<div>Do this:</div>

<br />
<div>set _NT_SYMBOL_PATH=srv*http://localhost:8080/yourserver/yourpath</div>
<br />
<div>If the pattern matches a line in symfilter.txt it will serve a 302 redirect to http://yourserver/yourpath/[the usual pdb request path]</div>
<div></div>
<div>

Note the syntax is slightly different than the original version.

Now that it's only serving redirects or failures it probably could use the http listener directly because the reasons for doing sockets myself are all gone.  But I didn't make that change.

</div>
<div>The code is here:</div>
<div></div>
<pre>using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Sockets;

namespace SymbolFilter
{
    class FilterProxy
    {
        // we'll accept connections using this listener
        static TcpListener listener;

        // this holds the white list of DLLs we do not ignore
        static List dllFilterList = new List();

        // default port is 8080, config would be nice...
        const int port = 8080;

        static void Main(string[] args)
        {
            // load up the dlls
            InitializeDllFilters();

            // open the socket
            StartHttpListener();

            // all real work happens in the background, if you ever press enter we just exit
            Console.WriteLine("Listening on port {0}.  Press enter to exit", port);
            Console.ReadLine();
        }

        static void InitializeDllFilters()
        {
            try
            {
                // we're just going to throw if it fails...
                StreamReader sr = new StreamReader("symfilter.txt");

                // read lines from the file
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    dllFilterList.Add(line.Trim().ToLowerInvariant());
                }

                sr.Close();

            }
            catch (Exception e)
            {
                // anything goes wrong and we're done here, there's no recovery from this
                Console.WriteLine(e.Message);
                Environment.Exit(1);
            }
        }

        // Here we will just listen for connections on the loopback adapter, port 8080
        // this could really use some configuration options as well.  In fact running more than one of these
        // listening to different ports with different white lists would be very useful.
        public static void StartHttpListener()
        {
            try
            {
                listener = new TcpListener(IPAddress.Loopback, port);
                listener.Start();
                listener.BeginAcceptTcpClient(new AsyncCallback(DoAcceptTcpClientCallback), listener);
            }
            catch (Exception e)
            {
                // anything goes wrong and we're done here, there's no recovery from this
                Console.WriteLine(e.Message);
                Environment.Exit(1);
            }

        }

        // when we accept a new listener this callback will do the job
        public static void DoAcceptTcpClientCallback(IAsyncResult ar)
        {
            // Get the listener that handles the client request.
            TcpListener listener = (TcpListener)ar.AsyncState;

            // I should probably assert that the listener is the listener that I think it is here

            // End the operation and display the received data on  
            // the console.
            try
            {
                // end the async activity and open the client
                // I don't support keepalive so "using" is fine
                using (TcpClient client = listener.EndAcceptTcpClient(ar))
                {
                    // Process the http request
                    // Note that by doing it here we are effectively serializing the listens
                    // that seems to be ok because mostly we only redirect
                    ProcessHttpRequest(client);
                }
            }
            catch (Exception e)
            {
                // if anything goes wrong we'll just move on to the next connection
                Console.WriteLine(e.Message);
            }

            // queue up another listen
            listener.BeginAcceptTcpClient(new AsyncCallback(DoAcceptTcpClientCallback), listener);
        }


        // we have an incoming request, let's handle it
        static void ProcessHttpRequest(TcpClient client)
        {
            // we're going to process the request as text
            NetworkStream stream = client.GetStream();
            StreamReader sr = new StreamReader(stream);

            // read until the first blank line or the end, whichever comes first
            var lines = new List();
            for (;;)
            {
                var line = sr.ReadLine();

                if (line == null || line == "")
                    break;

                lines.Add(line);
            }

            // e.g. "GET /foo.pdb/DE1EBC3EE7E542EA96B066229D3A40081/foo.pdb HTTP/1.1"
            var req = lines[0];

            // avoid case sensitivity issues for matching the pattern
            var reqLower = Uri.UnescapeDataString(req).ToLowerInvariant();

            // loop over available patterns, if any matches early out
            int i;
            for (i = 0; i &lt; dllFilterList.Count; i++)
            {
                if (reqLower.Contains(dllFilterList[i]))
                    break;
            }

            // if we didn't match, or it isn't a GET or it isn't HTTP/1.1 then serve up a 404
            if (i == dllFilterList.Count || !req.StartsWith("GET /") || !req.EndsWith(" HTTP/1.1"))
            {
                // you don't match, fast exit, this is basically the whole point of this thing
                Return404(client);
            }
            else
            {
                // this is the real work
                Console.WriteLine("Matched pattern: {0}", dllFilterList[i]);
                RedirectRequest(client, req);
            }
        }

        // cons up a minimal 404 error and return it
        static void Return404(TcpClient client)
        {
            // it doesn't get any simpler than this
            var sw = new StreamWriter(client.GetStream());
            sw.WriteLine("HTTP/1.1 404 Not Found");
            sw.WriteLine();
            sw.Flush();
        }

        // cons up a minimal 404 error and return it
        static void Return302(TcpClient client, string server, string url)
        {
            string line = String.Format("Location: http://{0}{1}", server, url);
            Console.WriteLine("302 Redirect {0}", line);

            // emit the redirect
            var sw = new StreamWriter(client.GetStream());
            sw.WriteLine("HTTP/1.1 302 Redirect");
            sw.WriteLine(line);
            sw.WriteLine();
            sw.Flush();
        }


        static void RedirectRequest(TcpClient client, string req)
        {
            // we know this is safe to do because we already verified that the request starts with "GET /"
            string request = req.Substring(5); // strip off the "GET /"
            request = request.Substring(0, request.Length - 9);  // strip off " HTTP/1.1"

            // we're looking for the server that we are supposed to use for this request in our path
            // the point of this is to make it so that you can set your symbol path to include
            // http://localhost:8080/your-sym-server/whatever
            // and your-sym-server will be used by the proxy
            int delim = request.IndexOf('/', 1);

            // if there is no server specified then we're done
            if (delim &lt; 0)
            {
                // serve up an error
                Return404(client);
                return;
            }

            // the target server is everything up to the / but not including it
            string targetServer = request.Substring(0, delim);

            // the new request URL starts with the first character after the |
            request = request.Substring(delim + 1);

            // if there isn't already a leading slash, then add one
            if (!request.StartsWith("/"))
                request = "/" + request;

            Return302(client, targetServer, request);
        }
    }
}
</pre>]]></content:encoded>
    </item>
    <item>
      <title>A little 64 bit follow-up</title>
      <link>https://docs.microsoft.com/archive/blogs/ricom/a-little-64-bit-follow-up</link>
      <pubDate>Mon, 11 Jan 2016 13:44:00 GMT</pubDate>
      <dc:creator><![CDATA[ricom]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ricom/2016/01/11/a-little-64-bit-follow-up/</guid>
      <description><![CDATA[I recently wrote a pair of at least slightly controversial articles about 64-bit vs. 32-bit...]]></description>
      <content:encoded><![CDATA[<p>I recently wrote a pair of at least slightly controversial articles about 64-bit vs. 32-bit applications and the performance costs associated with going to 64 bit.</p>
<p>They are <a href="http://blogs.msdn.com/b/ricom/archive/2016/01/04/64-bit-visual-studio-the-quot-pro-64-quot-argument.aspx">here</a> and <a href="http://blogs.msdn.com/b/ricom/archive/2015/12/29/revisiting-64-bit-ness-in-visual-studio-and-elsewhere.aspx">here</a>.</p>
<p>Some people thought I was nuts.</p>
<p>Some people provided benchmarks "proving" that 64 bit code is in fact faster than 32 bit code.</p>
<p>I guess the lesson for me here is that I can't say often enough that I only ever write approximately correct blog entries and YMMV should be stamped on top of everything.</p>
<p>But, just so you don't think I've lost my mind, here is some data.</p>
<p>These are recent builds of IE and Edge in 32 bit and 64 bit.&nbsp; Its the same code, or as close as possible to the same code.&nbsp; This is just the main engine of both plus the old script engine and the new script engine.</p>
<table style="width: 301px;" border="0" cellspacing="0" cellpadding="0"><colgroup><col width="64" /> <col width="84" /> <col width="89" /> <col width="64" /></colgroup>
<tbody>
<tr>
<td width="64" height="20">&nbsp;</td>
<td style="text-align: right;" width="84"><span style="font-family: Calibri; font-size: small;">32 bits</span></td>
<td style="text-align: right;" width="89"><span style="font-family: Calibri; font-size: small;">64 bits</span></td>
<td style="text-align: right;" width="64"><span style="font-family: Calibri; font-size: small;">Growth</span></td>
</tr>
<tr>
<td height="20"><span style="font-family: Calibri; font-size: small;">edgehtml.dll</span></td>
<td align="right"><span style="font-family: Calibri; font-size: small;">18,652,160</span></td>
<td align="right"><span style="font-family: Calibri; font-size: small;">22,823,936</span></td>
<td align="right"><span style="font-family: Calibri; font-size: small;">22.4%</span></td>
</tr>
<tr>
<td height="20"><span style="font-family: Calibri; font-size: small;">mshtml.dll</span></td>
<td align="right"><span style="font-family: Calibri; font-size: small;">19,322,880</span></td>
<td align="right"><span style="font-family: Calibri; font-size: small;">24,577,536</span></td>
<td align="right"><span style="font-family: Calibri; font-size: small;">27.2%</span></td>
</tr>
<tr>
<td height="20"><span style="font-family: Calibri; font-size: small;">chakra.dll</span></td>
<td align="right"><span style="font-family: Calibri; font-size: small;">5,664,256</span></td>
<td align="right"><span style="font-family: Calibri; font-size: small;">7,830,016</span></td>
<td align="right"><span style="font-family: Calibri; font-size: small;">38.2%</span></td>
</tr>
<tr>
<td height="20"><span style="font-family: Calibri; font-size: small;">jscript9.dll</span></td>
<td align="right"><span style="font-family: Calibri; font-size: small;">3,667,968</span></td>
<td align="right"><span style="font-family: Calibri; font-size: small;">4,895,232</span></td>
<td align="right"><span style="font-family: Calibri; font-size: small;">33.5%</span></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>This result is completely typical -- between 1.2 and 1.4x growth is very normal for mainstream code.&nbsp; This is not universal, but it's in line with what I've seen elsewhere.</p>
<p>Yes there are exceptions.&nbsp; Yes it totally depends on the codebase.</p>
<p>Now is this going to be slower?&nbsp; Almost certainly because bigger is slower.</p>
<p>Why almost?</p>
<p>Well, if the code has really good locality (e.g. you only use a tiny slice of it;&nbsp; e.g. you move from one well used slice to another well used slice)&nbsp; then it might be that the parts of the code that are hot at any given moment are still fitting well into the cache.&nbsp; But that's sort of a lie as well.&nbsp; You see in a real system there is pollution because device drivers are running and background processes are running and so it's never really the case that there is surplus cache capacity.&nbsp; In real systems extra cache capacity basically just creates the opportunity for your code to remain efficient in the presence of other normal workloads.&nbsp; Micro-benchmarks don't these effects.</p>
<p>I also said that the data is always bigger.&nbsp; People disagree, but there really is no room for disagreement here.&nbsp; I think we can all agree that going to 64 bits won't make your data smaller, so the best you can hope for is a tie.&nbsp; I also think you are going to have at least one pointer on the stack somewhere.&nbsp;&nbsp; So a tie isn't possible.&nbsp; Pedantic yes, but on point.&nbsp; The truth is that depending on your workload you will see varying amounts of growth and no shrinkage.&nbsp; If your growth is sufficiently small, or the locality of the data is sufficiently good, then the extra cache misses from size growth will not be so bad.&nbsp; Micro-benchmarks will often still fit in the cache on a 64 bit system.&nbsp;</p>
<p>Visual Studio is in a poor position viz data growth because it has a lot of pointer rich data structures.&nbsp; Microsoft Edge, Chrome, and Firefox&nbsp;are in relatively better positions because much of their data is not rich in pointers -- bitmaps for instance are essentially (minus some metadata) identical, strings are identical, styles can be stored densely.&nbsp; As a consequence browsers will suffer less than VS would.</p>
<p>The bottom line is that this will vary a great deal based on your workload.&nbsp; But the price of cache misses should not be underestimated.&nbsp; A modern processor might retire over 200 instructions in the same time as one cache miss.&nbsp; More in extreme situations.&nbsp; That's a lot to recover from, extra registers won't do it universally.</p>
<p>I wrote about these phenomena in greater detail in <a href="http://blogs.msdn.com/b/ricom/archive/2014/09/28/performance-quiz-14-memory-locality-alignment-and-density-suggestions.aspx">this article from 2014</a>.&nbsp; That article includes a quantitative examination of data growth and locality effects.</p>
<p>I had some top level observations for anyone contemplating a port:</p>
<p>* if you think you're going to get free speed, you have it backwards -- you start in the hole, you will have to win back your losses with processor features, definitely possible but not a given</p>
<p>* if you're going to 64 bits because you're out of memory but you could fix your memory problems with "let's not do this stupid thing anymore" then you should do that</p>
<p>* if you're avoiding 64 bits because you keep saying "I can stay in 32 bits if I do this new stupid thing" then you're kidding yourself, crazy workarounds are doomed</p>
<p>Visual Studio in 2009 was definitely in the situation whereby avoiding some dumb stuff we could make it fit.&nbsp; I don't know where it is in 2016.</p>
<p>This also excludes collateral benefits you get from going to 64 bits, such as avoiding the wow subsystem, cleaning up an otherwise potentially clumsy architecture, greater security due to increased exploit difficulty.&nbsp; Some of these benefits may be very important to your workload/customers.&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>64-bit Visual Studio -- the "pro 64" argument</title>
      <link>https://docs.microsoft.com/archive/blogs/ricom/64-bit-visual-studio-the-pro-64-argument</link>
      <pubDate>Mon, 04 Jan 2016 02:48:00 GMT</pubDate>
      <dc:creator><![CDATA[ricom]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ricom/2016/01/04/64-bit-visual-studio-the-pro-64-argument/</guid>
      <description><![CDATA[&nbsp;
[I don't have to go out on a limb to acknowledge that is the worst article I've ever...]]></description>
      <content:encoded><![CDATA[<div style="padding-top: 1em;">
<p>&nbsp;</p>
<p>[I don't have to go out on a limb to acknowledge that is the worst article I've ever written.&nbsp; I wrote it in the wee hours one morning in a rotten mood and it shows.&nbsp; There are far too many absolutes that should have been qualified and the writing style is too aggressive for no good reason.&nbsp; I'm not taking it down because there are worthy comments, and I refuse to try to pretend it never happened.&nbsp; But I absolutely regret writing this article in this way.&nbsp; If you choose to read this, use a large sanity filter and look at some of the comments and the follow-up for qualifications to help see what I'm getting at.]</p>
<p><span style="font-family: Calibri; font-size: small;">[This article is in response to an earlier posting which you can find <a href="http://blogs.msdn.com/b/ricom/archive/2015/12/29/revisiting-64-bit-ness-in-visual-studio-and-elsewhere.aspx">here</a>]<br /><br />I&rsquo;ve been reading some of the commentary on my post about 64-bit Visual Studio which is really about 64-bit vs. 32-bit generally using Visual Studio as an example and I have to say that for the most part, I&rsquo;m pretty disappointed with the arguments being put forth in favor of 64-bits. </span></p>
<p>[Some less than charitable and totally unnecessary text removed.&nbsp; I blame myself for writing this at 2:30am.&nbsp; It was supposed to be humorous but it wasn't.]</p>
<p><span style="font-family: Calibri; font-size: small;">There is an argument to be made here, but there is also a great deal of ignoring of the real issue going on here.</span></p>
<p><span style="font-family: Calibri; font-size: small;">Let&rsquo;s actually go about doing the job of properly attacking my position the way I think it should be attacked, shall we?</span></p>
<p><span style="font-family: Calibri; font-size: small;">I start with some incontrovertible facts.&nbsp; Don&rsquo;t waste your time trying to refute them, you can&rsquo;t refute facts. You can have your own opinion, but can&rsquo;t have your own facts. </span></p>
<p><span style="font-family: Calibri; font-size: small;">The relevant facts are these:</span></p>
<p><span style="font-family: Calibri; font-size: small;">-the same algorithm coded in 64-bits is bigger than it would be coded in 32-bits</span></p>
<p><span style="font-family: Calibri; font-size: small;">-the same data coded for 64-bits is bigger than it would be coded in 32-bits</span></p>
<p><span style="font-family: Calibri; font-size: small;">-when you run the same code, but bigger encoding, over the same data, but bigger encoding, on the same processor, things go slower</span></p>
<p><span style="font-family: Calibri; font-size: small;">-any work I can possibly do has an opportunity cost which will mean there is some other work I can&rsquo;t do</span></p>
<p><span style="font-family: Calibri; font-size: small;">All righty, it&rsquo;s hard to argue with those.</span></p>
<p><span style="font-family: Calibri; font-size: small;">Now let&rsquo;s talk about the basis I use for evaluation.</span></p>
<p><span style="font-family: Calibri; font-size: small;">-I get points for creating a great customer experience</span></p>
<p><span style="font-family: Calibri; font-size: small;">-I get no points for using technology X, only for the experience, using fewer technologies for the same experience is better than using more</span></p>
<p><span style="font-family: Calibri; font-size: small;">-I get no points for using more memory, not even enabling the use of more memory, only for the experience, using less memory for the same experience is better than using more</span></p>
<p><span style="font-family: Calibri; font-size: small;">OK, so in short, I begin with &ldquo;64-bits gets no free inherent value, it has to justify itself with Actual Benefits like everything else.&rdquo;</span></p>
<p><span style="font-family: Calibri; font-size: small;">We cannot make a compelling argument with fallacies like &ldquo;32 bits was better than 16 therefore 64 must be better than 32&rdquo;, nor will we get anywhere with &ldquo;you&rsquo;re obviously a short-sighted moron.&rdquo;</span></p>
<p><span style="font-family: Calibri; font-size: small;">But maybe there is something to learn from the past, and what&rsquo;s happened over the last 6 years since I first started writing about this.</span></p>
<p><span style="font-family: Calibri; font-size: small;">For Visual Studio in particular, it has been the case since ~2008 that you could create VS extensions that were 64-bits and integrate them into VS such that your extension could use as much memory as it wanted to (Multi-process, hybrid-process VS has been a thing for a long time).&nbsp; You would think that would silence any objections right there -- anyone who benefits from 64-bits can be 64-bits and anyone who doesn&rsquo;t need 64-bits can stay 32-bits.&nbsp; It&rsquo;s perfect, right?</span></p>
<p><span style="font-family: Calibri; font-size: small;">Well, actually things are subtler than that.</span></p>
<p><span style="font-family: Calibri; font-size: small;">I could try to make the case that the fact that there are so few 64-bit extensions to VS is proof positive that they just aren&rsquo;t needed.&nbsp; After all, it&rsquo;s been nearly 8 years, there should be an abundance of them.&nbsp; There isn&rsquo;t an abundance, so, obviously, they&rsquo;re not that good, because capitalism.</span></p>
<p><span style="font-family: Calibri; font-size: small;">Well, actually, I think that argument has it exactly backwards, and leads to the undoing of the points I made in the first place.</span></p>
<p><span style="font-family: Calibri; font-size: small;">The argument is that perhaps it&rsquo;s just too darn hard to write the hybrid extensions.&nbsp; And likewise, perhaps it&rsquo;s too darn hard to write &ldquo;good&rdquo; extensions in 32-bits that use memory smartly and page mostly from the disk.&nbsp; Or maybe not even hard but let&rsquo;s say inefficient &ndash;from either an opportunity cost perspective or from a processor efficiency perspective; and here an analogy to the 16-bit to 32-bit transition might prove useful. </span></p>
<p><span style="font-family: Calibri; font-size: small;">It was certainly the case that with a big disk and swappable memory sections any program you could write in 32-bit addressing could have been created in 16-bit (especially that crazy x86 segment stuff).&nbsp; But would you get good code if you did so?&nbsp; And would you experience extraordinary engineering costs doing so?&nbsp; Were you basically fighting your hardware most of the time trying to get it to do meaningful stuff?&nbsp; It was certainly that case that people came up with really cool ways to solve some problems very economically because they had memory pressure and economic motivation to do so. &nbsp;Those were great inventions.&nbsp; But at some point it got kind of crazy.&nbsp; The kind of 16-bit code you had to write to get the job done was just plain ugly.</span></p>
<p><span style="font-family: Calibri; font-size: small;">And here&rsquo;s where my assumptions break down.&nbsp; In those cases, it&rsquo;s *not* the same code.&nbsp; The 16-bit code was slow ugly crapola working around memory limits in horrible ways and the 32-bit code was nice and clean and directly did what it needed to do with a superior algorithm.&nbsp; Because of this, the observation that the same code runs slower when it&rsquo;s encoded bigger was irrelevant.&nbsp; It wasn&rsquo;t the same code!&nbsp; And we all know that a superior algorithm that uses more memory can (and often does) outperform an inferior algorithm that&rsquo;s more economical in terms of memory or code size.</span></p>
<p><span style="font-family: Calibri; font-size: small;">Do we have a dearth of 64-bit extensions because it&rsquo;s too hard to write them in the hybrid model?</span></p>
<p><span style="font-family: Calibri; font-size: small;">Would we actually gain performance because we wouldn&rsquo;t have to waste time writing tricky algorithms to squeeze every byte into our 4G address space?</span></p>
<p><span style="font-family: Calibri; font-size: small;">I don&rsquo;t have the answer to those questions.&nbsp; In 2009 my thinking was that for the foreseeable future, the opportunity cost of going to 64-bits was too high compared to the inherent benefits. &nbsp;&nbsp;Now it&rsquo;s 2016, not quite 7 years since I first came to that conclusion.&nbsp; Is that still the case?</span></p>
<p><span style="font-family: Calibri; font-size: small;">Even in 2009 I wanted to start investing in creating a portable 64-bit shell* for VS because I figured the costs would tip at some point.&nbsp; </span></p>
<p><span style="font-family: Calibri; font-size: small;">I don&rsquo;t work on Visual Studio now, I don&rsquo;t know what they&rsquo;re thinking about all this.</span></p>
<p><span style="font-family: Calibri; font-size: small;">If there&rsquo;s a reason to make the change now, I think I&rsquo;ve outlined it above.&nbsp; </span></p>
<p><span style="font-family: Calibri; font-size: small;">What I can say is that even in 2016, the choice doesn&rsquo;t look obvious to me.&nbsp;&nbsp; The case for economy is still strong.&nbsp; And few extensions are doing unnatural things because of their instruction set &ndash; smart/economical use of memory is not unnatural.&nbsp; It&rsquo;s just smart.<br /><br />*the "Shell" is the name we give to the core of VS (what you get with no extensions, which is nearly nothing, plus those few extensions that are so indispensable that you can't even call it VS if you don't have them, like solutions support -- that's an extension]</span></p>
</div>]]></content:encoded>
    </item>
    <item>
      <title>Revisiting 64-bit-ness in Visual Studio and elsewhere</title>
      <link>https://docs.microsoft.com/archive/blogs/ricom/revisiting-64-bit-ness-in-visual-studio-and-elsewhere</link>
      <pubDate>Tue, 29 Dec 2015 15:25:00 GMT</pubDate>
      <dc:creator><![CDATA[ricom]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ricom/2015/12/29/revisiting-64-bit-ness-in-visual-studio-and-elsewhere/</guid>
      <description><![CDATA[[Due to popular interest I also wrote a piece that is "pro" 64 bits here]
The topic of 64-bit...]]></description>
      <content:encoded><![CDATA[<div style="padding-top: 1em;">[Due to popular interest I also wrote a piece that is "pro" 64 bits <a href="http://blogs.msdn.com/b/ricom/archive/2016/01/04/64-bit-visual-studio-the-quot-pro-64-quot-argument.aspx">here</a>]</div>
<div style="padding-top: 1em;"><br /><br />The topic of 64-bit Visual Studio came up again in a tweet and, as usual, I held my ground on why it is the way it is.&nbsp; Pretty predictable.&nbsp; But it&rsquo;s not really possible to answer questions about your position in a tweet, hence this posting.</div>
<div style="padding-top: 1em;">I&rsquo;m going to make some generalizations to make a point and you should really not use those generalizations to make specific conclusions about specific situations.&nbsp; This is as usual in the spirit of giving approximately correct advice rather than writing a novel.</div>
<div style="padding-top: 1em;">Let&rsquo;s say I convert some program to a 64-bit instruction set from a 32-bit instruction set.&nbsp; Even without knowing anything about the program I can say with pretty good confidence that the most probable thing that will happen that it will get bigger and slower.</div>
<div style="padding-top: 1em;">&ldquo;But Rico! More RAM better!&nbsp; More bits better!&rdquo;</div>
<div style="padding-top: 1em;">In the immortal words of Sherman T. Potter: &ldquo;Horse hucky!&rdquo;</div>
<div style="padding-top: 1em;">I&rsquo;ve said this many times before, for the most part there is no space/speed trade-off.&nbsp; Smaller IS Faster.&nbsp; In fact, in a very real sense Space is King.&nbsp; Or if you like Bigger is Slower.&nbsp; Part of the reason we study space/speed tradeoffs is because they are exotic beasts and it&rsquo;s important to understand how it is that using more memory, inherently more expensive, can strangely give you a speedup, and under what conditions that speedup actually persists.</div>
<div style="padding-top: 1em;">Let&rsquo;s break it down to two cases:</div>
<div style="padding-top: 1em;">1.&nbsp;Your code and data already fits into a 32-bit address space</div>
<div style="padding-top: 1em;">Your pointers will get bigger; your alignment boundaries get bigger; your data is less dense; equivalent code is bigger.&nbsp; You will fit less useful information into one cache line, code and data, and you will therefore take more cache misses.&nbsp; Everything, but everything, will suffer.&nbsp; Your processor's cache did not get bigger.&nbsp; Even other programs on your system that have nothing to do with the code you&rsquo;re running will suffer.&nbsp; And you didn&rsquo;t need the extra memory anyway.&nbsp; So you got nothing.&nbsp; Yay for speed-brakes.</div>
<div style="padding-top: 1em;">2.&nbsp;Your code and data don&rsquo;t fit into a 32-bit address space</div>
<div style="padding-top: 1em;">So, you&rsquo;re now out of address space.&nbsp; There are two ways you could try to address this.</div>
<div style="padding-top: 1em;">a)&nbsp;Think carefully about your data representation and encode it in a more compact fashion</div>
<div style="padding-top: 1em;">b)&nbsp;Allow the program to just use more memory</div>
<div style="padding-top: 1em;">I&rsquo;m the performance guy so of course I&rsquo;m going to recommend that first option.&nbsp;</div>
<div style="padding-top: 1em;">Why would I do this?</div>
<div style="padding-top: 1em;">Because virtually invariably the reason that programs are running out of memory is that they have chosen a strategy that requires huge amounts of data to be resident in order for them to work properly.&nbsp; Most of the time this is a fundamentally poor choice in the first place.&nbsp; Remember good locality gives you speed and big data structures are slow.&nbsp; They were slow even when they fit in memory, because less of them fits in cache.&nbsp; They aren&rsquo;t getting any faster by getting bigger, they&rsquo;re getting slower.&nbsp; Good data design includes affordances for the kinds of searches/updates that have to be done and makes it so that in general only a tiny fraction of the data actually needs to be resident to perform those operations.&nbsp; This happens all the time in basically every scalable system you ever encounter.&nbsp;&nbsp; Naturally I would want people to do this.</div>
<div style="padding-top: 1em;">Note: This does NOT mean &ldquo;store it in a file and read it all from there.&rdquo;&nbsp; It means &ldquo;store *most* of it in a file and make it so that you don&rsquo;t read the out-of-memory parts at all!&rdquo;</div>
<div style="padding-top: 1em;">This approach is better for customers; they can do more with less.&nbsp; And it&rsquo;s better for the overall scalability of whatever application is in question.&nbsp; In 1989 the source browser database for Excel was about 24M.&nbsp; The in-memory store for it was 12k.&nbsp; The most I could justify on a 640k PC.&nbsp; It was blazing fast because it had a great seek, read and cache story.</div>
<div style="padding-top: 1em;">The big trouble with (b) is that Wirth&rsquo;s Law that &ldquo;software manages to outgrow hardware in size and sluggishness&rdquo; applies basically universally and if you don&rsquo;t push hard nothing ever gets better.&nbsp; Even data that has no business being as big as it is will not be economized.&nbsp; Remember, making it so that less data needs to be accessed to get the job done helps everyone in all the cases, not just the big ones.</div>
<div style="padding-top: 1em;">So what does this have to do with say Visual Studio? *</div>
<div style="padding-top: 1em;">I wrote about <a href="http://blogs.msdn.com/b/ricom/archive/2009/06/10/visual-studio-why-is-there-no-64-bit-version.aspx">converting VS to 64-bit in 2009</a> and I expect the reasons for not doing it then mostly still apply now.</div>
<div style="padding-top: 1em;">Most of Visual Studio does not need and would not benefit from more than 4G of memory.&nbsp; Any packages that really need that much memory could be built in their own 64-bit process and seamlessly integrated into VS without putting a tax on the rest.&nbsp;&nbsp; This was possible in VS 2008, maybe sooner.&nbsp; Dragging all of VS kicking and screaming into the 64-bit world just doesn&rsquo;t make a lot of sense. **</div>
<div style="padding-top: 1em;">Now if you have a package that needs &gt;4G of data *and* you also have a data access model that requires a super chatty interface to that data going on at all times, such that say SendMessage for instance isn&rsquo;t going to do the job for you, then I think maybe rethinking your storage model could provide huge benefits.</div>
<div style="padding-top: 1em;">In the VS space there are huge offenders.&nbsp; My favorite to complain about are the language services, which notoriously load huge amounts of data about my whole solution so as to provide Intellisense about a tiny fraction of it.&nbsp;&nbsp; That doesn&rsquo;t seem to have changed since 2010.&nbsp;&nbsp; I used to admonish people in the VS org to think about solutions with say 10k projects (which exist) or 50k files (which exist) and consider how the system was supposed to work in the face of that.&nbsp; Loading it all into RAM seems not very appropriate to me.&nbsp; But if you really, no kidding around, have storage that can&rsquo;t be economized and must be resident then put it in a 64-bit package that&rsquo;s out of process.&nbsp;</div>
<div style="padding-top: 1em;">That&rsquo;s your best bet anyway.&nbsp; But really, the likelihood that anyone will have enough RAM for those huge solutions even on a huge system is pretty low.&nbsp; The all-RAM plan doesn&rsquo;t scale well&hellip;&nbsp; And you can forget about cache locality.</div>
<div style="padding-top: 1em;">There&rsquo;s other problems with going 64 bit.&nbsp; The law of unintended consequences.&nbsp; There&rsquo;s no upper limit on the amount of memory you can leak.&nbsp; Any badly behaved extension can use crazy amounts of memory, to the point where your whole system is unusable. ***</div>
<div style="padding-top: 1em;">But, in general, using less memory is always better advice than using more.&nbsp; Creating data structures with great density and locality is always better than &ldquo;my representation is a n-way tree with pointers to everything everywhere&rdquo;</div>
<div style="padding-top: 1em;">My admonition for many years has been this:&nbsp; Think about how you would store your data if it were in a relational database.&nbsp; Then do slices of that in RAM.&nbsp;&nbsp; Chances are you&rsquo;ll end up in a much better place than the forest of pointers you would have used had you gone with the usual practice.&nbsp; Less pointers, more values.</div>
<div style="padding-top: 1em;">This isn&rsquo;t about not wanting a great experience for customers, nothing could be further from the truth.&nbsp; It&rsquo;s about advocating excellence in engineering rather than just rubberstamping growth.&nbsp; This is basically my &ldquo;brand.&rdquo;</div>
<div style="padding-top: 1em;">
<div style="padding-top: 1em;">* I don't work on Visual Studio anymore, don't read this as any indication of future plans or lack of plans because I literally have no idea</div>
</div>
<div style="padding-top: 1em;">** there are significant security benefits going to 64-bit due to address randomization and you do get some code savings because you don&rsquo;t need the WOW subsystem, but VS is so big compared to those libraries that doesn&rsquo;t really help much, it was a big factor for MS Edge though</div>
<div style="padding-top: 1em;">*** Also happens in MS Edge</div>]]></content:encoded>
    </item>
    <item>
      <title>Pit of Success for Organizations</title>
      <link>https://docs.microsoft.com/archive/blogs/ricom/pit-of-success-for-organizations</link>
      <pubDate>Wed, 16 Dec 2015 20:28:00 GMT</pubDate>
      <dc:creator><![CDATA[ricom]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ricom/2015/12/16/pit-of-success-for-organizations/</guid>
      <description><![CDATA[Many years ago I coined the phrase &ldquo;Pit of Success&rdquo; for software. People had used that...]]></description>
      <content:encoded><![CDATA[<p><span style="font-family: Calibri; font-size: small;">Many years ago I coined the phrase <a href="http://blogs.msdn.com/b/brada/archive/2003/10/02/50420.aspx">&ldquo;Pit of Success&rdquo;</a> for software. People had used that turn of phrase before to mean landing in a situation where their own success was awful, but that&rsquo;s not how I meant it.&nbsp; What I meant was that that state-of-the art software frameworks were too hard to use, too many potential problems, and it was like having to walk some horribly difficult path to succeed.&nbsp; I wanted success to be as easy as falling into a great big pit, so that instead of saying &ldquo;gotcha&rdquo; us framework developers could say &ldquo;nope, that works too, you win again!&rdquo; </span></p>
<p><span style="font-family: Calibri; font-size: small;">You just can&rsquo;t help but fall in the pit for the win.</span></p>
<p><span style="font-family: Calibri; font-size: small;">I like this metaphor because it&rsquo;s provocative and it&rsquo;s geometric.&nbsp; It&rsquo;s about changing the rules so that people do the right things by default, and so, win in three easy steps:</span></p>
<ol>
<li><span style="font-family: Calibri; font-size: small;">Use framework</span></li>
<li><span style="font-family: Calibri; font-size: small;">Do obvious/easy/natural things</span></li>
<li><span style="font-family: Calibri; font-size: small;">Profit</span></li>
</ol>
<p><span style="font-family: Calibri; font-size: small;">I think about many things this way, especially longer term things, like affecting behavior in an organization.</span></p>
<p><span style="font-family: Calibri; font-size: small;">Imagine that systems of your organization are like a complicated piece of terrain.&nbsp; The people operating in the system are little balls rolling around.&nbsp; Victory is some sweet spot in the terrain somewhere.&nbsp;&nbsp; Depending on where Victory is it might be pretty tricky to get there.&nbsp; Maybe it&rsquo;s up some big hill.&nbsp; Maybe there&rsquo;s a lot of potholes.&nbsp; Maybe the path isn&rsquo;t very direct.</span></p>
<p><span style="font-family: Calibri; font-size: small;">If you had a Pit of Success organization, then Victory would literally be this GIANT hole in the middle that you just automatically fall into.&nbsp; You can&rsquo;t help but win.</span></p>
<p><span style="font-family: Calibri; font-size: small;">Anyone work at a place like that?&nbsp; </span></p>
<p><span style="font-family: Calibri; font-size: small;">Me either.</span></p>
<p><span style="font-family: Calibri; font-size: small;">Here&rsquo;s the kicker.&nbsp; The terrain tends to get worse rather than better as things get complicated.&nbsp; For pretty simple reasons too.&nbsp; For instance, new parts of the system tend to be based on the old parts.&nbsp; So, say you have part of the terrain that&rsquo;s full of potholes.&nbsp; Yup, naturally when adding to the system people are going to copy them, making EVEN MORE potholes for people to fall into.</span></p>
<p><span style="font-family: Calibri; font-size: small;">Soon you get a situation where making any kind of progress requires complicated manuals and so forth.&nbsp; Step to the left.&nbsp; Avoid the spikes, don&rsquo;t break your ankles on any of those holes, roll uphill over two hills, don&rsquo;t crash into any obstacles, and maybe if you&rsquo;re lucky you can claim victory.</span></p>
<p><span style="font-family: Calibri; font-size: small;">Now you can either try to make your organization more effective by teaching everyone the rules, and I guess that doesn&rsquo;t hurt, some rules are probably pretty good, or you can go about the business of making the terrain better.&nbsp; Change the shape of some of those hills so that people tend to roll in the right direction.&nbsp; Move the victory circle somewhere easy to get to.&nbsp;&nbsp; And OMG fill in those potholes so people stop cloning them!</span></p>
<p><span style="font-family: Calibri; font-size: small;">If you do these things, then over time you will tend to get more people automatically going down good paths to success.&nbsp; They might not even know you did it, they just suddenly start winning doing the obvious &ldquo;downhill&rdquo; stuff.</span></p>
<p><span style="font-family: Calibri; font-size: small;">I&rsquo;ll leave you with my favorite Pit of Success metaphor.&nbsp; It&rsquo;s an apocryphal story about the hamburger recipes of Dean Martin and Frank Sinatra.</span></p>
<p><span style="font-family: Calibri; font-size: small;">It seems Mr. Martin was famous for his excellent burgers and had encoded a fabulous way to prepare them.&nbsp; There were many important instructions which I don&rsquo;t remember but stuff like getting only the best meat, and getting the right spices, and cooking time, and of course the perfect wine.&nbsp; </span></p>
<p><span style="font-family: Calibri; font-size: small;">Mr. Sinatra&rsquo;s recipe on the other hand goes like this:</span></p>
<ol>
<li><span style="font-family: Calibri; font-size: small;">Go to Deano&rsquo;s house</span></li>
<li><span style="font-family: Calibri; font-size: small;">Ask Deano to make you a hamburger</span></li>
<li><span style="font-family: Calibri; font-size: small;">Drink Deono&rsquo;s wine.</span></li>
</ol>
<p><span style="font-family: Calibri; font-size: small;">I&rsquo;m liking that recipe :)</span></p>
<p><span style="font-family: Calibri; font-size: small;">Now if you&rsquo;re a framework author, or an organizational architect then maybe you&rsquo;ve gotta be more like Dean but it&rsquo;s be really nice if pretty much everyone else could be Frank.</span></p>
<p>&nbsp;</p>
<p>Shameless plug:&nbsp; please have a look at my words on <a href="http://blogs.msdn.com/b/ricom/archive/2015/12/11/supporting-women-in-computer-science-part-2.aspx">Women in Computer Science</a> if you haven't already</p>
<p><span style="font-family: Calibri; font-size: small;">&nbsp;</span></p>]]></content:encoded>
    </item>
    <item>
      <title>Supporting Women in Computer Science (Part 2)</title>
      <link>https://docs.microsoft.com/archive/blogs/ricom/supporting-women-in-computer-science-part-2</link>
      <pubDate>Fri, 11 Dec 2015 11:17:00 GMT</pubDate>
      <dc:creator><![CDATA[ricom]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ricom/2015/12/11/supporting-women-in-computer-science-part-2/</guid>
      <description><![CDATA[Last night I wrote about my new scholarship (previous post)
Today I have something to ask.
I know...]]></description>
      <content:encoded><![CDATA[<p>Last night I wrote about my new scholarship (<a href="http://blogs.msdn.com/b/ricom/archive/2015/12/10/rico-mariani-women-in-computer-science-scholarship.aspx">previous post</a>)</p>
<p>Today I have something to ask.</p>
<p>I know my subscribers include tons of competent software engineers. I have a request/challenge for you. Especially the men.</p>
<p>Will any of you stand with me?</p>
<p>All you have to do is this:</p>
<p>1) Do something for a school, any school that means something to you</p>
<p>2) Seek people to mentor, my focus is on women, but you can have any focus that means something to you</p>
<p>3) Tell your friends this is something you stand for</p>
<p>That's all. It's been one of the most rewarding things I've ever done and I wish it for all of you.</p>
<p><a class="_58cn" href="https://www.facebook.com/hashtag/heforshe?source=feed_text&amp;story_id=10153166566131244" data-ft="{&quot;tn&quot;:&quot;*N&quot;,&quot;type&quot;:104}"><span class="_58cl">‪#&lrm;</span><span class="_58cm">heforshe</span></a></p>]]></content:encoded>
    </item>
    <item>
      <title>Rico Mariani Women in Computer Science Scholarship</title>
      <link>https://docs.microsoft.com/archive/blogs/ricom/rico-mariani-women-in-computer-science-scholarship</link>
      <pubDate>Thu, 10 Dec 2015 21:54:00 GMT</pubDate>
      <dc:creator><![CDATA[ricom]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ricom/2015/12/10/rico-mariani-women-in-computer-science-scholarship/</guid>
      <description><![CDATA[Just a few minutes ago I signed my part of the papers to create the Rico Mariani Women in Computer...]]></description>
      <content:encoded><![CDATA[<p>Just a few minutes ago I signed my part of the papers to create the Rico Mariani Women in Computer Science scholarship at my alma, the <a href="https://uwaterloo.ca/">University of Waterloo</a>.</p>
<p>I don't usually put my name on things, especially charitable giving, but in this case it was important to me to not only give the money but to actually come out and say "This is something I stand for."</p>
<p>A few years ago (ok 10) I was profoundly affected by one of the Microsoft Think Week Papers I was asked to referee&nbsp;and it changed the way that I thought about women in CS. It showed me that there were things I could personally do, right away, that would make a difference, and so I set about doing them. I wrote about some of these things a few days ago when I discussed Privilege.</p>
<p>I'm putting my name on this <a class="_58cn" href="https://www.facebook.com/hashtag/heforshe?source=feed_text&amp;story_id=10153165478891244" data-ft="{&quot;tn&quot;:&quot;*N&quot;,&quot;type&quot;:104}"><span class="_58cl">‪#&lrm;</span><span class="_58cm">heforshe‬</span></a> effort because I hope to inspire others to do the same (it's super easy) and because in addition to the money, I want to give the winners some kind of leg up. An industry contact could be invaluable to a person trying to break into the field. If I'm lucky, some of them will come to trust me for advice. If I'm very lucky I'll make a difference for at least some of them. At worst, there will be a few people in the world with smaller student loans.</p>
<p>This is just one small thing, but if many of us help a little in this way, we can do something really meaningful.</p>
<p>[Edit: naturally I *cough* totally planned that this would happen during Computer Science Week&nbsp; -- serendipity FTW]</p>
<p>See <a href="http://blogs.msdn.com/b/ricom/archive/2015/12/11/supporting-women-in-computer-science-part-2.aspx">Part 2</a></p>]]></content:encoded>
    </item>
  </channel>
</rss>