Trying out the profiler on the VPC

I’ve frequently heard the question asked, “Can I use the profiler on a Virtual PC?”  It has even come up on the blog feedback a few times.  My answer has always been, “Theoretically, yes.”  I didn’t want to post this answer externally until I’d actually gotten around to trying it myself.

I’ve finally been nagged into it.

In my limited experience with our VirtualPC product, it has quite impressed me with its functionality.  However, it does not emulate the hardware performance counters upon which the profiler implicitly depends.  For this reason, you can not run the sampling profiler using a performance counter based interrupt.  My collegue Ishai pointed out* that you should be able to use page-fault or system-call based sampling, but the VPC has a different problem with these modes that is still under investigation.

Instrumentation based profiling will work on the VPC.  However, as I’ve already mentioned, there is a bug check issue with the driver when it unloads.  Fortunately, instrumentation based profiling doesn’t rely on the presence of the driver.

By renaming the driver to prevent the profiling monitor from installing it at startup, I was able to use instrumentation based profiling on the VPC.  This is obviously just a workaround,  but I hope this will allow you to investigate some of our tools in the comfort of a VirtualPC environment.

Here is how you can prevent the driver from loading on your VPC installation.

  • Use regedit to delete the key HKLM\CurrentControlSet\Services\VSPerfDrv.

  • Find C:\Program Files\Microsoft Visual Studio\Enterprise Developer Tools\Performance Tools\VSPerfDrv.sys, and rename it to something silly like __VSPerfDrv.sys__, or delete it.

  • Reboot your VPC to ensure that the driver isn’t installed

Happy hunting!

I’m pretty sure Ishai was hired to point out things I do wrong.  Fortunately, he usually points out solutions as well.