News for hackers. Stuff that matters.
Re:Gallery of Processor Cache Effects by joseraul on Sunday December 21, 2014 @09:57AM (#8779866)
Most examples are classical cache effects, but the last one is such a puzzle.

  A++; C++; E++; G++; 	448 ms
  A++; C++; 	        518 ms
How can incrementing 2 variables be slower than incrementing 4 variables?
Re:Gallery of Processor Cache Effects by to3m on Sunday December 21, 2014 @01:01PM (#8780362)
Perhaps the result is an average rather than the best result?

I wondered about this too so I tried it on my PC, though I had to make up my own timing code since the author doesn't say what he was doing. Results for me were more in line with what I'd expect, with both 4-variable cases being the same speed and the 2-variable one being a bit quicker. (All the data for the loop will fit into 2 or 3 cache lines so I don't think there's much chance you'll see any memory effects being measured.)

This is compiling for x64.

Re:Gallery of Processor Cache Effects by shizcakes on Sunday December 21, 2014 @12:51PM (#8780333)
This feels like a Nagle-esque[1] issue (maybe delaying actions until a buffer fills, for example?)

[1] http://blogs.msdn.com/b/windowsazurestorage/archive/2010/06/...