title: Confused about cpu cache memory
body: <p>I'm really confused about CPU Caches.</p>
  
  <p>I've tried looking up how they work but all I got was that:</p>
  
  <ol>
  <li>it is faster than main memory.</li>
  <li>You can't pragmatically check if your program is using it or not.</li>
  <li>Not using it significantly slows down your program.</li>
  <li>You are not suppose to care about it.</li>
  <li>If you don't care about it, your programs can run 20 times slower.</li>
  <li>Your best bet at managing cache is educated guesses with timing.</li>
  <li>Different caches may use different caching algorithms.</li>
  </ol>
  
  <p>What confuses me about them is:</p>
  
  <ol>
  <li>How does a cache check for hits? Does it have a processor inside of it?</li>
  <li>How does caching interact with process swapping? I'm afraid that even if my program is 1kb and my cache is 32kb, the cpu may not exploit the locality because it would keep swapping it anyway.</li>
  </ol>
  
  <p>Thanks for any help!</p>