r/cpp • • Jan 29 '26

Cache Explorer: a visual and interactive profiler that shows you exactly which lines of code cause cache misses

Built a visual cache profiler that uses LLVM instrumentation + simulation to show you exactly which lines cause L1/L2/L3 misses in your C and C++ code (Rust support in active development).

  • Hardware-validated accuracy (±4.6% L1, ±9.3% L2 vs Intel perf)
  • Source-level attribution (not just assembly)
  • False sharing detection for multi-threaded code
  • 14 hardware presets (Intel/AMD/ARM/Apple Silicon)
  • MESI cache coherence simulation

It's like Compiler Explorer but for cache behavior, providing instant visual feedback on memory access patterns. MIT licensed, looking for feedback on what would make it more useful or even just things you like about it.

GitHub

243 Upvotes

18 comments sorted by

View all comments

Show parent comment

2

u/ShoppingQuirky4189 Jan 30 '26

Currently the scaling isn't too great with large projects, which is definitely the next thing I want to optimize for. Restricting the instrumentation is a good idea as well, are you thinking a sort of annotation feature where you could signal if you want to include/exclude a given function?

1

u/ohnotheygotme Feb 02 '26

There's probably a few different ways that could each be workable. Maybe variations of the following:

  • A runtime API to turn collection on/off. Everything would be instrumented but nothing will be collected until enabled. This way I can enable it once I know I'm about to do the interesting work and then turn it off once I'm done. All executing code across the process will be tracked. It's just a controllable hammer.
  • A source annotation of sorts. It's a scalpel rather than a hammer but it might require very tedious annotations through very deep call stacks to see the complete picture.

Basically the larger scenario is:

  • This is large application. There will be 100's of billions of cache misses before getting to the point of interest. I don't care about these misses.
  • The point of interest is a loop, which calls into several other methods.
  • I'd like to get an idea of what's going on with this loop, and all contained function calls.
  • I don't want to see or record data for the 100's of billions of cache misses after this loop completes.

Anything that supports that general workflow can be made to work :)