views:

292

answers:

3

I'm compiling a vc8 C++ project in a WinXp VmWare session. It's a hell of a lot slower than gcc3.2 in a RedHat VmWare session, so I'm looking at Task Manager. It's saying a very large percentage of my compile process is spent in the kernel. That doesn't sounds right to me.

Is there an equivalent of strace for Win32? At least something which will give me an overview of which kernel functions are being called. There might be something that stands out as being the culprit.

+2  A: 

Not exactly strace, but there is a way of getting visibility into the kernel call stack, and by sampling it at times of high CPU usage, you can usually estimate what's using up all the time.

Install Process Explorer and make sure you configure it with symbol server support. You can do this by:

  1. Installing WinDebug to get an updated dbghelp.dll
  2. Set Process Explorer to use this version of dbghelp.dll by setting the path in the Options | Configure Symbols menu of Process Explorer.
  3. Also in the same dialog, set the symbols path such that it includes the MS symbol server and a local cache.

Here's an example value for the symbol path:

SRV*C:\symbolcache*http://msdl.microsoft.com/download/symbols

(You can set _NT_SYMBOL_PATH environment variable to the same value to have the debugging tools use the same symbol server and cache path.) This path will cause dbghelp.dll to download symbols to local disk when asked for symbols for a module that doesn't have symbols locally.

After having set up Process Explorer like this, you can then get a process's properties, go to the threads tab, and double-click on the busiest thread. This will cause Process Explorer to temporarily hook into the process and scan the thread's stack, and then go and look up the symbols for the various return addresses on the stack. The return addresses's symbols, and the module names (for non-MS third-party drivers) should give you a strong clue as to where your CPU time is being spent.

Barry Kelly
+3  A: 

Windows Resource Kit contains a tool called kernrate. It's a sampling profiler. It can profile entire system or a particular process. By default, its resolution is on a module level, but can be tuned down to several bytes. You should be fine with default resolution as you'll see which modules/drivers are consuming most of the time.

Here is some info regarding its use.

atzz
A more up-to-date version of kernrate is in the Windows Driver Kit.
bk1e
A: 

VmWare support should be address that question. It's probably somewhere in the VmWare implementation.

You can use for example IrpTracker that give you an idea what is going on in the kernel. Another option is using kernel debugger i.e WinDbg. If the cpu load very high just randomly breaking in the debugger and looking on the call stack can give you an idea who is the driver behind the cpu load. But as i stated i will guess that it will be some VmWare component. It worth to check if the problem persist on same computer on WinXP without emulation.

Ilya
I'm not suggesting using WinDbg. Process Explorer automatically dumps the stack of *running* applications. It simply needs dbghelp.dll from WinDbg; it doesn't use anything else.
Barry Kelly
Updated. Will it include kernel stack as well ?
Ilya