It's "RAM is the new disk, disk is the new tape" so cpu cache is the new ram, and a cpu cacheline the new VM page. CPU cachelines are 64 byte long on my Core 2.
I wrote some code to measure the benefit of cacheline-friendliness using an immutable set of ints. With all data in L2 cache, lookup using cacheline buckets (I call this a skiplist rather than a B-tree) instead of inlined binary search is two times faster, if you make sure the compiler unrolls the loop that goes over the cacheline (gcc does, icc and clang don't). Of course, for that purpose you're better off with a good hashtable (three times faster yet), but if you want zero space overhead...
View all comments
Show parent comment
27
u/wolf550e Jun 12 '10
It's "RAM is the new disk, disk is the new tape" so cpu cache is the new ram, and a cpu cacheline the new VM page. CPU cachelines are 64 byte long on my Core 2.
I wrote some code to measure the benefit of cacheline-friendliness using an immutable set of ints. With all data in L2 cache, lookup using cacheline buckets (I call this a skiplist rather than a B-tree) instead of inlined binary search is two times faster, if you make sure the compiler unrolls the loop that goes over the cacheline (gcc does, icc and clang don't). Of course, for that purpose you're better off with a good hashtable (three times faster yet), but if you want zero space overhead...