views:

3074

answers:

9

Does windows have any decent sampling (eg. non-instrumenting) profilers available? Preferably something akin to Shark on MacOS, although i am willing to accept that i am going to have to pay for such a profiler on windows.

I've tried the profiler in VS Team Suite and was not overly impressed, and was wondering if there were any other good ones.

[Edit: Erk, i forgot to say this is for C/C++, rather than .NET -- sorry for any confusion]

A: 

I'm not sure what a non-instrumenting profiler is, but I can say for .NET I love RedGate's ANTS Profiler. Version 3 beats the MS version for ease of use and Version 4, which allows arbitrary time slices, makes MS look like a joke.

Jonathan Allen
Sampling profilers work by observing your program's state periodically, and are thus non-invasive, and work on executables without the source code. (Though you'd probably need debugging information to resolve the function calls, etc.) -- correct me if I'm wrong.
aib
@aib: it certainly helps to have function names/stack layout info, yes, but of course .NET has that anyway (though it is possible to mutilate the names such that they are essentially numbers...). Line numbers don't hurt either, of course, and those you do need debug info for regardless.
SamB
+8  A: 

Intel VTune is good and is non-instrumenting. We evaluated a whole bunch of profilers for Windows, and this was the best for working with driver code (though it does unmanaged user level code as well). A particular strength is that it reads all the Intel processor performance counters, so you can get a good understanding of why your code is running slowly, and it was useful for putting prefetch instructions into our code and sorting out data layout to work well with the cache lines, and the way cache lines get invalidated in multi core systems.

It is commercial, and I have to say it isn't the easiest UI in the world.

Dickon Reed
VTune is a good tool, but its not free and it doesn't understand Windows internals.
Foredecker
vtune also has a terrible, terrible UI, i found it utterly dreadful.
Matt Joiner
+7  A: 

For Windows, check out the free Xperf that ships with the Windows SDK. It uses sampled profile, has some useful UI, & does not require instrumentation. Quite useful for tracking down performance problems. You can answer questions like:

Who is using the most CPU? Drill down to function name using call stacks.

Who is allocating the most memory?

Outstanding memory allocations (leaks)

Who is doing the most registry queries?

Disk writes? etc.

XPerf seems great, but it cannot run on XP, it needs Vista or Server 2007 or newer. A pitty - the functionality sounds really great, callstack captures based on sampling profiling would be handy.
Suma
XPerf depends heavily on the revamped ETW in Vista, one of the little known improvements in Vista/Server08.
argh.. yeah.. xp incompatible. so it starts... :(
vilaca
Xperf uses ETW infrastructure added with Windows Vista. Because of this it cannot profile an application; but profiles the entire system. And it requires administrative, command-line, access to start and stop logging. i.e. not very friendly
Ian Boyd
+2  A: 

I have tried Intel's vtune with a rather large project about two years ago. It was an instrumenting profiler then and it took so long to instrument the DLL that I was attempting to profile that I eventually lost patience after an hour.

The one tool that I have had quite good success and which i would highly recommend is that of AQTime. It not only provides excellent performance profiling resources but it also doe really good memory profiling which has been of significant help to me in tracking down memory leaks.

Jon Trauntvein
Intel VTune has two modes: instrumenting (can produce callstacks and callgraphs) and sampling (hotspots only, no callstacks).
Suma
+1  A: 

We use both VTune and AQTime, and I can vouch for both. Which works best for you depends on your needs. Both have free trial versions - I suggest you give them a go.

Greg Whitfield
I am trying to compare VTune and AQTime. Can you please provide more deatils of their features?
Amit Kumar
+3  A: 

The Windows Driver Kit includes a non-instrumenting user/kernel sampling profiler called "kernrate". It seems useful for profiling multi-process applications, applications that spend most of their time in the kernel, and device drivers (of course). It's also available in the KrView (Kernrate Viewer) and Windows Server 2003 Resource Kit Tools packages.

Kernrate works on Windows 2000 and later (unlike Xperf, which requires Vista / Server 2008). It's command-line based and the documentation has a somewhat intimidating list of options. I'm not sure if it can record call stacks or just the program counter. If you use a symbol server, make sure to put an up-to-date dbghelp.dll and symsrv.dll in the same directory as kernrate.exe to prevent it from using the ancient version of dbghelp.dll that is installed in %SystemRoot%\system32.

bk1e
+2  A: 

AMD's CodeAnalyst is FREE here

Die in Sente
+4  A: 

I know I'm adding my answer months after this question was asked, but I thought I'd point out a decent, open-source profiler: Very Sleepy.

It doesn't have the feature count that some of the other profilers mentioned before do, but it's a pretty respectable sampling profiler that will work very well in most situations.

Naaff
This looks like it can be a pretty good profiler. But it needs the ability to sample all threads in a process. And the process picker needs to include PID (since there are many Chrome.exe or iexplore.exe processes, but only one is the parent)
Ian Boyd
+1  A: 

Luke Stackwalker seems promising -- it's not as polished as I'd like, but it is open source and it does do something that seems very close to what @Mike Dunlavey keeps saying we ought to do. (Of course, it then tries to smoosh it all down into the typically-unhelpful call graphs that Mike is so weary of, but it shouldn't be too hard to fix that with the source as our ally.)

It even seems to count time spent waiting in the kernel, as far as I can tell...

SamB
Mike Dunlavey
@SamB: Chances are the reason they threw away the samples is they thought they would take too much storage. You know my answer to that. Only a small number of samples is needed to find the problems, especially if you can manually control sampling. A large number of samples gives you greater measurement precision, which you don't need.
Mike Dunlavey
@Mike: Hmm, that does sound worse than I might have been thinking (I, obviously, can't remember what I was *actually* thinking at the time ;-). Still... it seemed to be an awful lot closer to the desired tool than, say, Hello World is.
SamB
@SamB: I hoped so too. If I didn't have distractions like a real job and family, I would whip up a profiler, maybe starting from Luke Stackwalker source. I did actually build one in '93 for DOS. It did make a nice show, but for real work I fell back to the manual method. BTW, LTProf is pretty close, for Windows.
Mike Dunlavey