@GDCPresoReviews@mastodon.gamedev.place
2026-04-27 03:03 UTC
GDC 2017: "Cold, Hard Cache: Insomniac's Cache Simulator" by Andreas Fredriksson (@deplinenoise) of Insomniac Games https://gdcvault.com/play/1023962/Cold-Hard-Cache-Insomniac-s
This was interesting. What they were trying to do was find lines of code, across their entire project, that miss the cache a lot.
The way they do this is they run their game on PC, and they use x86's Trap Flag (in EFLAGS) to trap on every instruction. You can use Windows's Vectored Exception Handlers to catch the traps.
1/4
Replies (1)
-
@GDCPresoReviews@mastodon.gamedev.place 2026-04-27 03:08
At the end of the handler, you set the Trap Flag again, so the next instruction gets another trap. So your handler ends up getting called every time an instruction gets executed. In the handler, you can parse the instruction, and look at the register state to determine which memory accesses that instruction is performing. Now that you're seeing all the memory operations, you can model the behavior of a cache, to see whether you expect that operation to hit or miss. 2/4