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 entry were…

2

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…

9

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…

18

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…

28

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?  It’s…

6

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…

32

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.Length; num3 > 0; num3 -=…

28

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…

11

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…

22

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…

6