Embed Notice
HTML Code
Corresponding Notice
- Embed this notice@meso @Moon @mja
> pointer-chases,
Now that the memory bus is the slow thing, this is a killer. It's exaggerated in the case of chasing pointers across a disk, but if you iterate down a linked list, you are chasing pointers. An array, the memory controller will stream the whole thing, but if you can't find out the next address until loading the current address, that doesn't do you any good. So you dereference the current node to get at its data, it has a *next in it, you dereference that, and *then* you can find out what is next.
Back in The Day, memory traffic wasn't as expensive relative to other operations: if you could cache the result of dividing one number by another, you might actually want to do that. Nowadays, 90% (SERIOUSLY) of a CPU's time is spent waiting on the memory bus, so if you can calculate it in less than twice the number cycles it would take to do a round trip to the bus, you just calculate it. If you can arrange for it to be contiguous in memory, you always do that.