I am just running a while 1 loop and measuring cache miss.
int main() {
while(1);
}
This particular process is tied to one cpu(using taskset) and this cpu is isolated, meaning no other process can get scheduled on the same cpu. Now I start measuring cache performance using perf
and to my surprise last level cache miss is 42%.
22,579 cache-references (20.82%)
8,976 **cache-misses # 39.754 %** of all cache refs (20.83%)
4,414 **LLC-load-misses # 42.74%** of all LL-cache hits
I am surprised and I expected zero cache miss as I am not doing any memory operation. Any help/thoughts on this. cpu: model name : Intel(R) Xeon(R) CPU E5-2670 v3 @ 2.30GHz
Another experiment I did with giving a nano sleep of .1 milli second and cache miss reduced to less than 1%. I have no clue on whats going on.
Probably the perf counters are counting some events from kernel code in interrupt handlers. perf counter events aren't precise, so you'll get counts attributed to nearby instructions, and I guess for ops still in the pipeline when the kernel code did an
iret
. Or this may just be fully counting events that happened in kernel context, since it would be expensive to mess with perf-counters on every interrupt.Note that the cache-miss ratio only looks bad if you don't take into account how few cache accesses there are, total:
Timed on a Conroe Core2Duo E6600 (since I bricked my Intel SnB motherboard with Intel's broken BIOS updates).
cache-references
andcache-misses
are "Kernel PMU events", whileLLC-*
andL1-*
are "Hardware cache events", according toperf list
. I'm not sure what that means.