r/CodingHelp • • Jan 27 '26

[C++] CPU cache latency benchmark driving me nuts! Please help me out

Im developing my own CPU benchmark suite in c++ (visual studio). One of them involves measuring cache latency in NS and cache read bandwidth in GBs (l1+l2+l3). Our latency section seems pretty stable but the bandwidth is behaving weirdly. Most of the time, on a completely idle system, the L2 bandwidth scores can drop from 80gbs (which is the normal/average) to 60gbs.

The same with L3 bandwidth, i expect around 45gbs but sometimes can drop to 36gbs. I suspected simple CPU throttling, so I opened up HWINFO to inspect temps/clockspeeds when its running. Just to find out that when I have HWINFO open, the test goes back to behaving perfectly. As soon as I close HWINFO, back to dropping to the lower scores 80% of the time. ChatGPT has suggested a "keep alive" core doing some light work to keep the CPU ring awake and prevent any idling but I cannot get this to work. Any suggestions?

1 Upvotes

4 comments sorted by

View all comments

Show parent comment

1

u/Matthew_24011 Jan 28 '26

i got stability when disabling c states and ring down bin in the bios. it seemed that the c state setting was the most effective though. im trying to figure out how to implement code that can do something similar in windows, without bios tweaks. im experimenting with " Implement C1E disable via MSR 0x1FC ". I also made an exe which locked the ring to whatever ratio i choose (again within windows, no bios tweaks needed) and it seemed to work consistently until it didnt.