|[Home] [Credit Search] [Category Browser] [Staff Roll Call]||The LINUX.COM Article Archive|
|Originally Published: Wednesday, 14 June 2000||Author: J Olive|
|Published to: enhance_articles_hardware/Hardware Articles||Page: 1/1 - [Std View]|
Hardware Performance Monitoring For The Masses
Do you or does anyone you know suffer from bloated, slow code? When you are sleeping, do you dream of the day when you'll be able to get your hands on one of those logic analyzers so that some real performance benchmarking can be done on your programs? Well, cheer up, because if you own a Pentium Pro or better, you've got performance monitoring hardware just waiting to be fired up.
I was working on a project for my school (UAH) a while back and I had the need to do performance monitoring on some software that I was writing. While logic analyzers and the such may be more readily available to some, I was not as fortunate. I had to find a hardware solution for my problem. After talking with some folks at school, I found out something that I did not know. Intel has been putting performance monitoring registers on their processors since the good Pentium Pro.
There are two 40-bit performance monitoring registers, meaning that only two specific things can be monitored at once. The list of things that can be monitored with these registers would be too long to list in this article, but to give you a couple examples: data memory references, and the number of instructions retired, are among the many varied things that can be counted. To make use of these performance monitoring registers in Linux, some people over at UTK have written the Performance API (PAPI).
PAPI consists of a kernel patch and an API. To get started, you apply the PAPI kernel patch. The kernel patch adds an option in the kernel config script that allows you to have access to these registers. This makes it possible for your programs to directly access these registers via a system call. After applying the kernel patch, all that is left to do is install the API and you're ready to go.
Because of the extreme ease of installing and using PAPI, hardware performance monitoring on a home PC can become a reality. These registers can be used for anything from determining race conditions in your code to seeing where bottlenecks reside. There are also other processors besides those from Intel that offer performance monitoring registers. You can check the PAPI website to see if your hardware is supported.
J Olive - UAH LUG