Friday, February 20, 2009

Quick guide to analyze performance on windows platform

There are two methods to analyze performance of windows system.
  1. Use Visual Studio Team System‘s Performance Explorer to debug windows application.
  2. Use kernrate to analyze windows kernel.
To use VSTS's performance explorer, you need to install VSTS. You can use two ways to analyze an application, either sampling or instrumentation. Sampling has less overhead than the instrumentation. Basically, there are 5 steps.
  1. Run vsperfcmd to start analyzing process.
  2. Run your application
  3. Stop your application
  4. Run vsperfcmd to stop analyzing process.
  5. Use VSTS performance explorer to view the generated report.
MSDN has comprehensive guide on how to do these in details.To be honest, I prefer use command line for the first 4 steps. Beside, to view the functions' name in the report, you should properly configure the symbol path.

kernrate.exe is for windows 2000/XP/2003 to analyze kernel performance. It is included windows WDK toolkit. Running kernrate is simple, just type
kernate -j SYMBOL_PATH -z module
where -j is the symbol path of kernel modules, -z are the module you'd like to zoom in.

To download kernel symbol, you need to use symchk which is included in windows debugging tools. For example, following command download all symbols under c:\windows\system32\

symchk /r c:\windows\system32 /s  SRV*c:\symbols\*http://msdl.microsoft.com/download/symbols

Tuesday, February 10, 2009

overlapped I/O on windows

I recently studied winsock programming and discovered that overlapped I/O can be easily used to avoid buffer copy between user and system level. This is something I am not aware of on linux platform.

Windows Sockets 2.0: Write Scalable Winsock Apps Using Completion Ports