Performance Counter Information required

Nov 22, 2012 at 11:14 PM

I need to learn how performance counter works for my research project. I have understood how hardware supports the monitoring of events.Intel manual gives description on how the performance monitoring units on the chip helps to get the counters. I also have learned how the MSR module gets the information of the msr registers for various events.

I need to learn the following things.

1) How performance monitoring tools are used for multiple processes simultaneously. I think all the registers will be saved during context switch and are loaded when the process start again.Browsing Internet I got something like "pfm_context_load" and "pfm_context_unload" but it didn't had much info......-> I need more detailed information on how it works,so please provide some links,documentation which can help me achieve my understanding

2) Also how performance counters work in virtual environment? And what are the problems measuring the counters in such environment? I have browsed through few papers and have some info, But need more detail information.

So if anyone can guide me with some documentation on these topics or at least guide me on where should I search for all these info with be a great help! ...

If this is not the right forum then please direct me towards right place..



Nov 29, 2012 at 12:50 PM

Clint may be able to add more than I can as he is a Microsoft employee and has more access to things that I don't being a simple customer. There's a lot of information about performance counters out there in MSDN and Technet. But what you are referring to is the guts of how the performance counters are collected. That from what I have read varies depending on the setup of the counter itself, which can vary a lot.

Performance counters work the same way in a virtual enviornement as they do in a physical enviornement, however anything that has to use a clock may have a significant error margin (innacurate measurements) due to clock drift and associated issues when running in a virtual enviornement. Thus in hypervisored enviornements we use special perfomance counters in the host machine to measure things like system cpu in the guest machines.

I have a lot of resources for this information but not on me at the moment due to a presentation I am doing on the topic at CMG next week. Once I get a chance i will post some more for you that you can look at.

There is a MSDN forum for this topic (actuallty more than one) if you have MSDN access. It's



Nov 30, 2012 at 1:19 AM

Hi officialanup,

Kabaker55 is right. Performance counters can be created by anyone who follows the MSDN documentation on creating them. Everything depends on how the developer wrote the performance counter. For example, you could query a database for data, then use that data to compute the value of your own performance counter. Many of the operating system counters act differently was well. For example, the \System\Processor Queue Length counter is a point in time counter meaning the value of it will be exactly what it is when collected, but \LogicalDisk(*)\Avg. Disk sec/Read has a value that collects all of the I/O request packets that occurred since the last collection and creates an average from them. Other than that, I can't give you any deeper understanding because the counter code is Microsoft source code and is confidential.

In regards to virtual environments, Kabaker55 is right again. Anything that depends on the clock will be slightly skewed. With that said, counters like % Processor Time are skewed because they are measuring how often the processor is running ready threads, so a ready thread issued by a virtual machine that is delayed by the underlying hardware (such as when the hardware is overwhelmed), then the counter will report 100%, but it doesn't mean that the virtual process is actually getting 100% of a physical processor - it just means that there was always a ready thread running on the virtual processor. This is why virtual counters can be highly skewed. The important part is understanding what they are actually measuring.

Tony Voellm has a good blog entry describing this behavior: