Not a question, just a story, for those who are interested, and for random search engine users in the future. And a small warning: this isn't exact science.
I'm using Direct3D9 through SlimDX in my .NET rendering engine. Something that annoyed me for some time were random noticable frame stalls every now and then. I suspected that the garbage collector would be the problem, but I was not sure about that. I set up my code to be minimal and predictable, fired up PIX and profiled.
This told me that the major stalls are rather large (from a constant \~80Hz down to 22Hz and then up) and periodic. But also that there is another periodic -but for me imperceptible- change in the frame rate.
I added several of PIX' default counters to find correlations, but didn't find any. Then I searched for other counters, and found that .NET provides tons of handy performance counters, like this one that is related to garbage collection (to be honest, I didn't bother to read exactly what it does).
And a closeup:
So: there appeared to be a relation between the smaller deviations and garbage collection, but the large stalls had no relation without any .NET counter I tried (and I tried many of them). The smaller deviations that appear to have some relation with garbage collection are most of the time only fps increases, that is, the frame around such an event was rendered faster. The steady FPS is about 82Hz, the small FPS increases jump to 96Hz most of the time, or: from 122ms to 104ms, that is 17% faster.
The large stalls were still not fixed. In a moment of inspiration I decided to kill absolutely all unneeded processes, which gave this result:
The large stalls were gone! After a reboot, and killing the processes one by one with profiling in between, I found out that a program called SpeedFan caused the stalls, a program I use to monitor my CPU & hard drive temperatures.
- as usual, the cause of a problem is not always what you think, and:
- garbage collection appears to have influence on the performance, but not enough to perceive, and according to my experiments there was an increase of 17% most of the time around GC work.
I'll be happy to hear any comments and hope that this might help someone someday.
Hehe, nice little tale
I wonder why the SpeedFan program was causing those spikes...
May not be SpeedFan itself, but rather SpeedFan plus drivers. What kind of video and chipset do you have?
Try running with the /NOSMARTSCAN switch, or /NONVIDIAI2C if you have an NVidia card.