Rico Mariani's Performance Tidbits

Implying no warranties and conferring no rights: "AS IS" since 1988

Browse by Tags

Tagged Content List
  • Blog Post: Performance Quiz #14: Memory Locality etc. Bonus Round!

    [Note: I accidently pasted an x64 result in place of an x86 result. As it happens the point I was trying to make was that they were very similar, which they are, but they aren't identical... corrected.] Thanks to some careful readers I discovered why the shuffling factors discussed in my previous...
  • Blog Post: Performance Quiz #14: Memory Locality, x64 vs. x86, Alignment, and Density

    [ Note: Mystery of the shuffling is solved, the rand() method I was using returns only numbers between 0 and 32k, so shuffling was ineffective in large array sizes. I will post an update. Thank you Ryan! See the new entry for the updated results. ] It's been a very long time since I did a...
  • Blog Post: Performance Quiz #13 -- Linq to SQL compiled query cost -- solution

    Well is there really a "solution" at all in general? This particular case I think I constrained enough that you can claim an answer but does it generalize? Let's look at what I got first, the raw results are pretty easy to understand. The experiment I conducted was to run a fixed number of queries...
  • Blog Post: Performance Quiz #13 -- Linq to SQL compiled queries cost

    I've written a few articles about Linq now and you know I was a big fan of compiled queries in Linq but what do they cost? Or more specifically, how many times to you have to use a compiled query in order for the cost of compilation to pay for itself? With regular expressions for instance it's usually...
  • Blog Post: Performance Quiz #12 -- The Cost of a Good Hash -- Solution

    Well once again there have been many thoughtful replies to both the original question as well as the followup with hints . Recall the original question asked a bit of trivia: could you name 5 implementations of GetHashCode in the framework that do things you might not expect to see in a hash function...
  • Blog Post: Performance Quiz #12 -- The Cost of a Good Hash -- Some Help

    I continue to be astounded by what my readers can come up with. As usual I had a purpose for posing my last question and that purpose was to show that basically its hard to get a handle on what things cost in any kind of omnibus way. But imagine my surprise when Frank and Shuggy turned this into an...
  • Blog Post: Performance Quiz #12 -- The Cost of a Good Hash

    This quiz is a little bit different than some of my others. Here is System.String.GetHashCode public override unsafe int GetHashCode() { fixed (char* text1 = ((char*) this)) { char* chPtr1 = text1; int num1 = 0x15051505; int num2 = num1; int* numPtr1 = (int*) chPtr1; for (int num3 = this...
  • Blog Post: Performance Quiz #11: Ten Questions on Value-Based Programming : Solution

    In my last quiz I asked a few questions about a few hypothetical classes that might appear in a value-rich context. I styled my example in the form of some graphics library classes but the idea is a general one. Many contexts can and should be rich in values to get nice data density and the resulting...
  • Blog Post: Performance Quiz #11: Ten Questions on Value-Based Programming

    Some of you have probably heard one or more of my talks, or read the annotations I made in the Design Guidelines . If you have then you already know that I don't always agree with every suggested guideline. Especially not in every context. It's probably fair to say that one of the greatest areas of disagreement...
  • Blog Post: Performance Quiz #10 -- Thread local storage -- Solution

    I actually posted quiz #10 quite a while ago but a comment with the correct solution came in so quickly that I wasn't very motivated to post a followup. There are excellent links in the comments (thank you readers!) But now I'll have to make the quizzes harder :) The problem was to see what overhead...
  • Blog Post: Performance Quiz #10 -- Thread local storage

    It's time for another quiz! A very short one this time. If I need some thread local storage and I might need several entries should I use: Thread.GetData(slot) and Thread.SetData(slot, object) or should I make my own static member like this [ThreadStatic] static Dictionary<String,Object>...
  • Blog Post: Performance Quiz #9 -- extra innings due to dispatch stubs

    Well you'll recall that in the Performance Quiz #9 solution there was a surprising result where Test7 was actually faster than Test5 even though they appear to be doing basically exactly the same work. So my new challenge to you was to see if you can explain it. So, now this is your last chance to...
  • Blog Post: Performance Quiz #9 : IList&lt;T&gt; List and array speed -- solution

    Last week I posted Performance Quiz #9 for discussion. Well the comments have been just awesome and many people went right ahead and measured the results. Some of you have discovered the key point in this particular test: Arrays are magic. In the test case as given there's a great deal of repeated...
  • Blog Post: Performance Quiz #9 : IList&lt;T&gt; List and array speed

    A short and sweet quiz with lots of juicy discussion possibilities: public int Sum( IList < ushort > indices) { int result = 0; for ( int i = 0; i < indices.Count; i++) result += indices[i]; return result; } Considering only the time it takes to do the Sum (i.e. assuming we had already...
  • Blog Post: Performance Quiz #8 -- The problems with parsing -- Part 5

    And today we conclude our little saga with one final experiment, a little analysis and some comments. I hope you've enjoyed reading this series as much as I've enjoyed doing the experiments. First, as promised I created yet another version of this little parser. This version is very similar to the...
  • Blog Post: Performance Quiz #8 -- The problems with parsing -- Part 4

    In my last posting I made some recommendations about how to drastically improve the evaluation process based on the key observations that even the basic operations required to evaluate the truth of the facts were quite costly -- more so than all of the extra allocations. I suggested a plan like this...
  • Blog Post: Performance Quiz #8 -- The problems with parsing -- Part 3

    The thing about performance work is that it's very easy to be fooled into looking into the wrong areas. That's why you want your changes to be firmly grounded in data whenever they can be. Or if you're planning, you want to be thinking about what your customer experience needs to be, what the key metrics...
  • Blog Post: Performance Quiz #8 -- The problems with parsing -- Part 2

    There were some great comments from the initial posting which I encourage you to read. Many people latched on to the fact that GetToken(...) is doing a whole lot of allocations which is not something you generally want to see in a low level parsing function. That was very high on my own list of things...
  • Blog Post: Performance Quiz #8 -- The problems with parsing -- Part 1

    I think I like parsers too much, I end up writing about them a lot. Maybe that's because about one program in three is, loosely speaking, a parser of some kind. All the more reason why we should be very good about writing them. Unlike some of my previous quizes I'm not exactly sure where this one...
  • Blog Post: Performance Quiz #7 -- Generics Improvements and Costs -- Solution

    Believe it or not I actually spend a good amount of time thinking about my little quizzes hoping to come up with a small piece of code that illustrates a bunch of different things in a simple enough way that many people feel they can jump right in and comment. And also there should be a nice curve ball...
  • Blog Post: Performance Quiz #7 -- Generics Improvements and Costs

    Time for another quiz for you all, this is just a micro-benchmark so we want to be careful not to conclude too much but it's useful for understanding the costs and their origins. Consider the two snippets shown below: // choice #1, using Generics int total = 0; List<int> li = new List<int>...
  • Blog Post: Performance Quiz #6 -- Conclusion, Studying the Space

    I thought I would end this series by looking at the space costs of both solutions because it gives a real window into what I do every day and perhaps it's helpful to understand the multidimensional aspects of performance analysis. It's also interesting because space analysis tends to be more predictive...
  • Blog Post: Performance Quiz #6 -- Looking at the sixth cut

    Well, it's time for me to surrender. Sort of :) Raymond pulls out all the stops in his sixth version by painting a big bullseye on his biggest remaining source of slowness which is operator new. He turns in an excellent result here. On my benchmark machine I see the number drop from 124ms to 62ms...
  • Blog Post: Performance Quiz #6 -- Optimizing the Managed Version

    Well, I've been slacking off too long... sitting on my nice 124ms time and doing nothing. It's time I did something to the managed code. You'll recall I had some observations in my analysis of the managed code and basically I can summarize my thoughts as follows: a good parser touches each character...
  • Blog Post: Performance Quiz #6 -- The fifth cut goes foul!

    Well today Raymond hits a snag in version 5 of the program. I started by profiling the code as provided (in fact I had the .exe from Raymond himself so I didn't even have to build it). The new version is actually slower (start to finish) than the previous version. Why? Well there's a little bug in there...
Page 1 of 2 (38 items) 12