Event-based profiling

Event-based profiling is triggered by any one of the software-based events or any Performance Monitor event that occurs on the processor.

The primary advantages of event-based profiling over time-based profiling are the following:
  • The routine addresses are visible when interrupts are disabled.
  • The ability to vary the profiling event
  • The ability to vary the sampling frequency

With event-based profiling, ticks that occur while interrupts are disabled are charged to the proper routines. Also, you can select the profiling event and sampling frequency. The profiling event determines the trigger for the interrupt and the sampling frequency determines how often the interrupt occurs. After the specified number of occurrences of the profiling event, an interrupt is generated and the executing instruction is recorded.

The default type of profiling event is processor cycles. The following are various types of software-based events:
  • Emulation interrupts (EMULATION)
  • Alignment interrupts (ALIGNMENT)
  • Instruction Segment Lookaside Buffer misses (ISLBMISS)
  • Data Segment Lookaside Buffer misses (DSLBMISS)
The sampling frequency for the software-based events is specified in milliseconds and the supported range is 1 to 500 milliseconds. The default sampling frequency is 10 milliseconds.
The following command generates an interrupt every 5 milliseconds and retrieves the record for the last emulation interrupt:
# tprof -E EMULATION -f 5 
The following command generates an interrupt every 100 milliseconds and records the contents of the Sampled Instruction Address Register, or SIAR:
# tprof -E -f 100 
The following are other types of Performance Monitor events:
  • Completed instructions
  • Cache misses
For a list of all the Performance Monitor events that are supported on the processors of the system, use the pmlist command. The chosen Performance Monitor event must be taken in a group where we can also find the PM_INST_CMPL Performance Monitor event. The sampling frequency for these events is specified in the number of occurrences of the event. The supported range is 10,000 to MAXINT occurrences. The default sampling frequency is 10,000 occurrences.
The following command generates an interrupt after the processor completes 50,000 instructions:
# tprof -E PM_INST_CMPL -f 50000

Event-based profiling uses the SIAR, which contains the address of an instruction close to the executing instruction. For example, if the profiling event is PM_FPU0_FIN, which means the floating point unit 0 produces a result, the SIAR might not contain that floating point instruction but might contain another instruction close to it. This is more relevant for profiling based on Performance Monitor events. In fact for the proximity reason, on systems based on POWER4 and later, it is recommended that the Performance Monitor profiling event be one of the marked events. Marked events have the PM_MRK prefix.

Certain combinations of profiling event, sampling frequency, and workload might cause interrupts to occur at such a rapid rate that the system spends most of its time in the interrupt handler. The tprof command detects this condition by keeping track of the number of completed instructions between two consecutive interrupts. When the tprof command detects five occurrences of the count falling below the acceptable limit, the trace collection stops. Reports are still generated and an error message is displayed. The default threshold is 1,000 instructions.