Hacker News new | ask | show | jobs
by posix_compliant 1316 days ago
I have a(nother) question. If you’re iterating through a long array with chunksize larger than the cache line size, then every iteration of the loop will cause a cache miss. So it shouldn’t matter if it’s a power of two or not, every call to a[i]++ will be a cache miss. What gives?
1 comments

I think it only makes a difference if you ever want to go back to previous elements, like to iterate through the array again. Then it helps to have it in cache. Otherwise if you never go back (if you just iterate once), the best strategy should be to not store it in cache at all so that other things you have in cache can stay.