Performance Analysis with HWPMC

George V. Neville-Neil

FreeBSD has included support for Hardware Performance Monitoring Counters (hwpmc) for several years now. The hwpmc system provides access to counters that are present in all modern Intel and AMD CPUs, as well as other chipsets, and which give the programmer the ability to understand the low level performance issues that may effect their code. The capabilities provided by hwpmc are quite extensive and can be daunting to the first time user. This tutorial will cover basic usage of hwpmc as well as give several practical examples that are immediately relevant to both user space and kernel level programmers.