3 ms·
This is true in most cases. It is all about the data and algorithm in concert, rarely about either one. Badly laid out data can kill your cache. Well laid out d
by jacquesm 5y ago
This is true in most cases. It is all about the data and algorithm in concert, rarely about either one. Badly laid out data can kill your cache. Well laid out data with a crappy algorithm may outperform badly laid out data with a fantastic algorithm.
The ability to visualize the impact of your layout on caching is the fastest pay-off you'll ever have as a programmer, just knowing the sizes of your caches can already make a huge difference.
For instance: if you have a bunch of data and you need to do operations on that data it is much faster to pull in the data piecemeal, do all the operations on it bit-by-bit and then to move on to the next bit of data than to do several sequential passes over the data storing the intermediate results.
The difference in speed can be multiple orders of magnitude.