Request for PMU Counter Support on Context Switches in Instruments

Hi,

My name is Hani Nemati, and I work at Microsoft, where we support several macOS applications such as Microsoft Edge and Teams. I’m also the primary contributor to Microsoft Performance Tools for Apple (https://github.com/microsoft/Microsoft-Performance-Tools-Apple), an open-source project aimed at improving trace analysis across platforms.

We are exploring ways to enhance our performance tracing capabilities on macOS and are particularly interested in the ability to attach PMU (Performance Monitoring Unit) counters to context switch events during trace collection. For reference, this capability is supported on Linux via LTTng using the add-context option (https://lttng.org/man/1/lttng-add-context/v2.13), and on Windows through Windows Performance Recorder (WPR), which allows PMU counters to be added at the start and end of context switches, enabling delta computation.

Would it be possible to introduce similar support in Instruments for macOS?

I’d appreciate any guidance or suggestions you might have on this request.

Thank you,

Hani Nemati

Email: hanemati@microsoft

The CPU Counters modes for Guided configuration in Instruments 26 sample the underlying hardware counters at thread context switch.

It sounds like you might want something with more control, though. Could you create a feedback to request this functionality be added to the Manual configurations as well, along with your use cases?

Yes, Instruments already supports sampling PMU counters based on events (like every 1 mil instructions) and time intervals (like every 1ms). However, we are looking for the ability to capture counter deltas specifically at thread context switches. With that we could precisely calculate PMU counters delta. I will submit this request through Feedback Assistant.

Request for PMU Counter Support on Context Switches in Instruments
 
 
Q