Registry change for perfmon and PID data

Perfmon is a great tool for mining performance data on a server and has a slew of objects and counters to expose most any type of data.

As nice as it is, there is one thing that can be difficult to do, and that is to view data for temporary objects.  For example IIS worker processes only live until the next recycle or restart.  If there are many worker processes on the server, the default view doesn't allow you to tell which is which.

perfmonPIDChange-before

Notice in the screenshot that there are three w3wp.exe worker processes on this server in the section on the right, but you can't tell from this view which belongs to which worker process.

A co-worker of mind pointed me to this great registry setting today that takes care of this.  http://support.microsoft.com/kb/281884.  Through a simple registry change, you can view the PID of each worker process within perfmon.  It can be obtained without the registry change, but through extra effort.

As long as you know the PID, you can match it up to the app pool easily.  In IIS6, you can use iisapp.vbs.  In IIS7, you can use "appcmd list wp".  Of course Task Manager is a key tool that is often used in parallel to show active PIDs, worker processes and various other real-time counters.

The registry change is quick and painless.  In fact, after making the change, I closed the Add Counters windows in perfmon and opened it again and the PID was there immediately.  No restart necessary.

perfmonPIDChange-after

If you want to save a click or two, you can follow the following steps instead of doing the change manually:

Take the following indented text and save to your desktop and call it showPID.reg.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PerfProc\Performance]
"ProcessNameFormat"=dword:00000002

Double click, acknowledge the prompt and you're done!

Disclaimer: Any changes to the registry needs to be done with an awareness of the impact.  There is always the chance that some tool, or another administrator, needs this to be at the default setting.  While it is safe in most environments, I can't be held liable for any negative impact that this change has. 

8 Comments

  • This registry chagne does add the pid to the process entries, but what about the CLR counter data? There has to be a way to identify which w3wp#? but I cannot find it. How can you reliably associate CLR performance data with multiple app pools running? It doesn't even appear that w3wp#1 in one counter set matches w3wp#1 in another counter set.

  • I am trying to read .Net CLR Memory. I added the key, rebooted and I can't tell which w3wp# is my app?

  • More information: I am trying to view Perfmon remotely, do I need to import this registry key to the server?

  • Dan / Daryl,

    Good questions, they tie together. The issue with the IIS worker processes is that they only exist until the next time they are recycled or a server is rebooted. Then the PIDs change. So, when you are tracking something like this, understand that it's temporary and you need to refresh it often to make sure that the PID IDs are correct and that it's collect the data still.

    To get the ASP.NET PIDs, from the command line type "iisapp". That will give you a mapping of app pool names to PIDs.

  • Daryl, to answer your other question, yes, you'll need to install the registry key on the remote server that is running perfmon.

  • The registry change worked for me only after reboot. Mine is W2K3 64 bit Std edition. Thanks for the post.

  • Hi,

    I have added the registry and re booted my iis and server but still the .net counters are showing w3wp#1, w3wp#2 instead of PID.

    Please suggest.

    Gaurav Aggarwal

  • Hi Gaurav,

    Which version of Windows are you using? It sounds like you're doing everything correctly. My recommendation is to double check the registry key just in case something is slightly off. After changing it and rebooting it should change the behavior of that counter.

Comments have been disabled for this content.