Friday, June 12, 2009

New discussion group for PmcTools

The PmcTools project now has a new discussion group pmctools-discuss, hosted on groups.google.com.

If you have a question on how to use PmcTools, or about its internals, please ask it there.

Sunday, April 19, 2009

PmcTools talk at the Bangalore chapter of the ACM

In April 2009 I was invited to speak on FreeBSD/PmcTools by the Bangalore chapter of the ACM. The slides for this talk are available at: http://people.freebsd.org/~jkoshy/download/acm-apr-09.pdf (550KB, PDF).

This was an overview talk. The talk briefly touched upon: the motivations and goals of the project, the programming APIs, some aspects of the implementation and on possible future work.

Monday, February 09, 2009

Short updates

A couple of (lagged!) updates on my FreeBSD/PmcTools work:

  • In Nov'08, I added support for Intel™ Core 2™ PMCs to PmcTools (SVN #185363 and later changesets).

    More recently, Nokia, via Jeff Roberson, contributed basic support for the PMCs in the Core/i7™ CPU, the next member in the Core™ family of CPUs (SVN #187761).

    With these additions PmcTools supports most Intel CPUs that have PMCs in them. (I have plans to finish support for 166Mhz Pentium MMX™ CPUs soon.)

  • A couple of tricky bugs were tracked down and fixed:

    • The NMI handler code I had written for the amd64 architecture needed to be more robust than it was. Fixed in SVN #188065.

    • A bug in callchain capture code that would appear only under high loads and only on SMP machines. Fixed in SVN #186037.

    Thanks to Artem Belevich, Fabien Thomas, George Neville-Neil and Jeff Roberson for their assistance with debugging.

Friday, September 19, 2008

Timed measurements with pmcstat(8)

Every once in a while I get email asking for an option to pmcstat(8) that would allow hardware events to be measured for a specified time interval.

The good news is: pmcstat(8) already supports timed measurements — using /bin/sleep.

Here is how you would do it:

  • Timed system sampling would be done in the following manner:

    % pmcstat -S instructions -O logfile /bin/sleep 42

    This invocation allocates a system-scope sampling PMC (-S) and profiles the whole system while /bin/sleep executes, i.e., for 42 seconds.

  • Timed measurements on groups of processes are performed in a similar fashion:

    % pmcstat -d -p dc-misses -t '1234' /bin/sleep 24

    This invocation would allocate a process-scope counting PMC (-p) that counts data cache misses, attach it (-t) to the process with pid 1234 and its descendants (-d), and count for 24 seconds.

    Note that the '-t' option also takes regular expressions, so you don't need to know process ids beforehand. To count instructions executed by processes named 'httpd' for an hour you would use:

    % pmcstat -p instructions -t 'httpd' /bin/sleep 3600

The "Unix way" uses small tools, each of which does a defined task reasonably well and which are combined to perform more complex tasks. In the examples above, /bin/sleep manages time intervals and pmcstat(8) manages PMC based measurements.

When you combine them, voilĂ , you get timed PMC based measurements.