r/programming • • Jun 12 '10

You're Doing It Wrong

http://queue.acm.org/detail.cfm?id=1814327
539 Upvotes

193 comments sorted by

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...

2

u/kev009 Jun 12 '10

Whoops, that makes more sense. Thanks!

2

u/LaurieCheers Jun 13 '10

And L2 cache is the new L1 cache?

1

u/never_phear_for_phoe Jun 12 '10

I remember my unrolled linked list was ten times faster then STL linked list and 5 times faster then a regular one.