logoalt Hacker News

coolThingsFirsttoday at 12:19 PM2 repliesview on HN

Why doesn’t the machine fill up the other cache lines as well why is 64 bytes only and then a miss?


Replies

masklinntoday at 12:43 PM

They will absolutely do that (prefetching, they can even eagerly load what’s on the other side of a pointer).

However it requires additional hardware to recognize patterns which benefit from prefetching, and every time the CPU prefetches data which ends up not being used it has both burned energy and memory bandwidth, and evicted data from the cache which might be needed (cache pollution).

Liquid_Firetoday at 12:43 PM

It might sometimes prefetch the surrounding lines as well, but ultimately cache space is limited, so there is a trade-off. Every time you fill a line, you are throwing away something else that was cached there previously, which you may need again in the near future.