views:

911

answers:

6

I have a winforms application that normally is at about 2-4% CPU. We are seeing some spikes up to 27% of CPU for limited number of times. What is the best profiling tool to determine what is actually causing this spike. We use dottrace but i dont see how to map that to exactly the CPU spikes?

Appreciate the help

+1  A: 

I've used 2 profiling tools before - RedGate's ANTS profiler, and the built in profiler found in Visual Studio Team System.

It's been some time since I used RedGate's (http://www.red-gate.com/products/ants_profiler/index.htm) profiler, though I used the built in in Visual Studio 2008 fairly recently.

That being said, I felt that the RedGate product felt more intuitive to use. One thing that frustrated me back when I used the RedGate product was that I couldn't instruct the profiler to only profile my code starting at a certain point - I had a performance hit that couldn't be reached until a fair amount of code had already executed and therefore polluted my results. They may have added that feature since then.

The built in version for Visual Studio is only available in their very-high end versions of the product. Someone correct me if I am wrong, but I don't think even the "Professional" version has the profiler. I am currently using Team System Developer Edition, which does have the code analysis tools.

One thing the VS version does do though, is enable you to pause the profiling, and even start your app with profiling paused, so you can really focus on the performance of something very specific. This can be exceedingly helpful when you are trying to understand the analysis results.

EDIT: Both tools will show you memory usage, and the number of times a specific method was called, and how much time was spent in each method. What they do not do, to the best of my knowledge, is show you CPU usage at any given point in time. However, there are likely strong correlations between CPU usage and the amount of time spent in a given block of code.

If you can duplicate the CPU spikes consistently by invoking certain actions in the APP, then what I would do is try and get my hands on the VS profiler, start the app with profiling pause, enable profiling right before you do whatever typically results in the spike, and examine those results.

This assumes of course that you have some sort of deterministic behavior to recreate the spikes. If not ... you might considering threaded processes or garbage collection a candidate for your performance hit.

Matt
A: 

I’ve found DevPartner from Compuware http://www.compuware.com/ to be an excellent profiling tool. Unfortunately it looks like at the present time they don’t support VS 2008.

A: 

Also, is this spike actually worrisome? And on what kind of hardware are you seeing this? A spike to 27% on a quad-core CPU might be cause for worry, but not on an 800Mhz P3.

How long does it stay spiked? @Matt has a great point that garbage collection could be at fault. Or potentially swapping to disk.

Is it affecting overall system performance for a long time, or just a couple seconds now and then?

Not that finding a solution to this shouldn't be of concern, but how important is it?

warren
A: 

You can also learn a lot about your application with Sysinternal Process Explorer and Perfmon (like does the spike occur on a GC).

GvS
A: 

If your app is single thread, the best profiling tool is your IDE.

Added: Maybe it's obvious, but percent CPU usage is not a very clear concept. When your program is running at all, it's at 100%. When it's not, it's at 0%. So partial percents have to be based on some sort of smoothing integral over time. However, whatever it is, you are seeing a spike. Some profilers let you home in on such a spike and analyze just that interval.

Mike Dunlavey
A: 

The best one that will show you the spikes and allows you to drill down to see what is causing it is Xperf/Xperfview tools.

Check out http://msdn.microsoft.com/en-us/performance/cc825801.aspx

and http://msdn.microsoft.com/en-us/library/cc305221.aspx

these tools are based on ETW technology ( Event Tracing For Windows ), which gives you super accurate view of what is going on for your process and for the whole system.

These tools also allows you to capture traces for postmortem analysis, and also attach/detach feature. Hope this helps.

mfawzymkh
Was this informtion useful to you at all?
mfawzymkh