Saturday 4 May 2019

c++ - Debugging the CPU Caches

I'm currently trying to optimize my software for better CPU cache usage. There are some posts on SO which suggest that it's sometimes hard to guess what the CPU cache is doing and why there are some performance drops in certain cases. For example:





So in order to get a clue where the cache misses happen, I can run perf to get a count of cache misses and where they occur as well as valgrind --tool=cachegrind to simulate the caches (at least an L1 and a last-level cache).



It's really nice to know where cache misses happen, but I'd like to know why they happen (for example cache trashing etc.). Is there a way to explicitly pause the program and see whats inside the caches (maybe with the program running in valgrind and vgdb attached)?

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...