Frame rate stalls with Direct3D and .NET and an adventure in PIX

6aa952514ff4e5439df1e9e6d337b864
0
roel 101 Aug 06, 2009 at 11:42

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.

pix0.png

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).

pix1.png

And a closeup:

pix1zoom.png

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:

pix2.png

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.

To conclude:
- 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.

2 Replies

Please log in or register to post a reply.

46407cc1bdfbd2db4f6e8876d74f990a
0
Kenneth_Gorking 101 Aug 06, 2009 at 14:03

Hehe, nice little tale :)

I wonder why the SpeedFan program was causing those spikes…

8676d29610e6c98d6dd2d9c38528cd9c
0
alphadog 101 Aug 10, 2009 at 20:17

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.