Debug Tools to analyse IIS process:
This article focus on taking memory dumps from IIS to determine which code is taking more time and to analyse which calls hangs/causes more CPU usage.
To take dumps,download the following.
To start with you need to download the debugging tools which can be found at http://msdn.microsoft.com/en-us/windows/hardware/gg463016
. Install it on the machine(webserver) where application is running in IIS to take dumps.
Download symbols from http://msdn.microsoft.com/en-us/windows/hardware/gg463028
and install or you can copy to shared path.
Steps to take dumps:
Get the process ID for the IIS worker process. You can get either from taskmanager and selecting PID to get it or Run IISapp from C:\<windowsdirectory>\Syst
Adplus will take dump at current state of CPU/IIS process. Make sure to take dumps when CPU is very high. Now goto path where you installed debugging tools earlier.i.e(C:\Program Files\Debugging Tools for Windows (x86)). Here we need to run adplus command. Example(C:\Program Files\Debugging Tools for Windows (x86)>adplus.vbs -hang -p 492) 492 is process id from step1.
This will create the dump in same path with date and timestamp. The directory contains the dmp file, txt file, adplus report, process list with PID appended.
Steps to analyse the results:
Now that we have taken dumps you can analyse on the same machine or on different machine.
Goto Start->Program files->Debugging tools for windows(x64) and open WinDbg. It will open the Dump editor.
Goto File -> select Open Crash Dump and select the dmp file taken from Step2.It will open the small command window and will have command box to type.
You need to load symbols from Install2(from above)i.e C:\symbols or \\sharepath\symbols.
Type in small command window: .sympath+ C:\symbols
To load symbols Type: .reload
To load mscorwks lib Type: .loadby sos mscorwks
To display time consumed by each thread Type: !runaway
Output will be something like this...
User Mode Time Thread Time
92:25b0 0 days 0:01:43.546
96:2418 0 days 0:01:39.796
22:2314 0 days 0:01:39.671
Now to check the thread which hangs/causes high cpu Type: ~92s
To view the calls Type: !clrstack this will display all the methods/call from the code which is running at that point of time.You can further analyse the code for optimization.
Some of the commands which can be helpful.
- to set symbols
!help - will give all the commands.
Cheat sheet for the commands can be found @ http://geekswithblogs.net/.netonmymind/archive/2006/03/14/72262.aspx