Michele Giuseppe Fadda
Michele Giuseppe Fadda

Reputation: 1332

Can I measure branch prediction failures on modern Intel Mac OS X?

I would like to measure branch prediction fails on Xcode for Intel processors on Mac OS X, with the obvious intent of speed optimization.

Is there a way to program XCode's Instruments in order to achieve this?

I have already checked, and this information is unfortunately not present in Xcode documentation. I suspect this could be achieved with some custom setting.

The purpose is identifying optimization problems such as this one: Why is it faster to process a sorted array than an unsorted array?

I am aware that an Intel commercial solution exists, for Intel Processors running on Linux and Windows. On OS X you can apparently only monitor a remote Intel processor running on a Linux or Windows system.

Rather than a commercial tool, I would prefer a way to set/program Xcode and Apple tools to gain at least a minimum of visibility on this issue.

Upvotes: 2

Views: 1139

Answers (2)

that other guy
that other guy

Reputation: 123570

For anyone else struggling with this, in Instruments 9.2:

  • Select Counters
  • Go to File>Recording Options
  • Select "Sample by: Events"
  • Choose an event name (see docs), in this case "BR_MISP_RETIRED.CONDITIONAL":

Screenshot of Recording Options in Instruments

Upvotes: 6

osgx
osgx

Reputation: 94375

There are hardware performance counters (PMC) in XCode's Instuments:

https://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/MeasuringCPUUse.html

There are hidden by default branch events in Window > Manage PM Events, according to http://meandmark.com/blog/2011/10/event-profiler-and-counters-instruments/

Upvotes: 2

Related Questions