title: Cache misses on macOS
body: <p>There are some questions about this topic, but none has a real answer. The question is: <em>how can I measure L1, L2, L3 (if any) cache misses on macOS</em>?</p>
  
  <p>The problem is not that macOS does not provide, in theory, those values even without any external tool. In <strong>Instruments</strong> we could use the <em>Counters</em> and go to <strong>Recording Options...</strong> as in here:</p>
  
  <p><a href="https://i.stack.imgur.com/jXnzO.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/jXnzO.jpg" alt="counters"></a></p>
  
  <p>However, there is no L1 cache miss or L2, but <em>a huge list of possible items</em> that could be selected:</p>
  
  <p><a href="https://i.stack.imgur.com/iNlpn.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/iNlpn.jpg" alt="events"></a></p>
  
  <p>So, when measuring L1 and L2 <strong>cache misses</strong> (or even L3 if there is any), how can I count them? </p>
  
  <p>Which of the list is the "<em>cache misses</em>" I should pay attention to in order to retrieve that magic "cache miss" number? </p>