1

Why is cache split in two levels (L1&L2) instead of being one whole cache?Is it because it saves time?I feel like Im missing something

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • Does this answer your question? [Why is the size of L1 cache smaller than that of the L2 cache in most of the processors?](https://stackoverflow.com/questions/4666728/why-is-the-size-of-l1-cache-smaller-than-that-of-the-l2-cache-in-most-of-the-pro) – Peter Cordes Jun 09 '20 at 17:39

1 Answers1

0

Because fast cache is expensive (L1 is faster than L2 is faster than L3 ...). By splitting it up in layers you can expand the size of the cache at a relatively low cost. Even the "slow" cache will be orders of magnitude faster than retrieving data from RAM memory (or, even worse, HDD). Efficient heuristics exist to guess what data should be in which level of cache. Some more information is available in the answers here: What is "cache-friendly" code?

The following video about Herb Sutter talking about caching contains a whole lot of very useful information about caches (it becomes particularly relevant for this question around the 12 min mark).

Community
  • 1
  • 1
Marc Claesen
  • 16,778
  • 6
  • 27
  • 62