views:

632

answers:

2

I've been dealing with this problem for my thesis. The goal is to develop a .net server monitoring tool specifically for windows 2K8 servers. So far, all I can access are software performance counters. Meaning those that are available through perfmon and the WMI classes.

But then there's also the issue that I need to be able to monitor things like the number of TLB-misses that occur, or the current memory bandwidth. And that's where I'm stuck... As there is no standard .net way to get these counters I've been reading through some code from open source programs such as Oprofile. But since I don't know what exactly I'm looking for, not much progress has been made on that front.

So I humbly ask if there is somebody here, who has any experience with this kind of thing and could help me out a bit.

Thanks in advance.

+3  A: 

The most widely used library for reading performance counters is the Performance API (PAPI). PAPI is actually two API's (high-level and low-level). I tend to use the low level one since I find it more intuitive, but that could just be me.

There are two types of events in PAPI. Preset events are supposed to be platform-agnostic, though they can differ subtly depending on how they're counted internally. They do include TLB misses and memory stalls, so maybe you could start there. If that doesn't suit your needs, you may want to have a look at native events, which are specific to your particular hardware and typically include every event that the hardware can count. Use papi_native_aval to get a list of these.

PAPI has support for Windows, but I've actually never tried it. I couldn't find anything in the docs/readmes that referred specifically to Windows 2008, but at the very least perhaps you can look through the source to see how to access the counters you need, even if you can't access them directly.

If you need more, then maybe take a look at perfmon2, which the newer versions of PAPI make use of on Linux, if it's available.

tgamblin
Thank you very much, I'll definitely look into this right away!If I have any more questions, I'll be back ^^
Tom De Bie
A: 

There is no real distinction between "Software" and "Hardware" performance counters. A performance counter simply presents some type of data. It can get that data from wherever it wants, including from some hardware source.

Developing your own performance counter is relatively straightforward. There is information and example code on MSDN.

The tricky bit would be getting the actual TLB miss data, inside your performance counter module. Look at the spec for the CPU you are using, it is probably available at the Intel (or AMD or whatever) web site. It should give some info on how to get the actual values. The open source code you have may be useful as an example.

Michael J
I've never actually heard anyone say "software performance counter" before now, but "hardware performance counter" *is* a pretty specific term for special registers that can be configured to count hardware events. See http://en.wikipedia.org/wiki/Hardware_performance_counter.
tgamblin
A hardware performance counter is calculated in hardware (surprise!), and thus it does not alter the performance characteristics of the program. A software performance counter must be in-lined into the execution stream somehow, resulting in a Heisenberg situation - if you measure it, you alter it.
Tom
@tgamblin -- Fair 'nuff. The original poster mentioned perfmon and wmi counters, which have interfaces to a variety of software and hardware sources. I hadn't heard the expression "hardware counter" to refer to registers on the CPU, but it has been a couple of years since I did CPU performance stuff so I guess I'm behind the latest stuff.
Michael J