HP Caliper Advisor Rule Writer Guide
Figure 1-3 Typical Rule Used by the HP Caliper Advisor
# Rule: itlb_misses
#
# Author: HP Caliper team (caliper-help@cup.hp.com)
#
# Version: 1.1 (7/18/2006)
#
# Description: Looks for a minimal percentage of itlb misses which might be
# reduced by specifying larger text pages.
#
# Limitations: Executable objects
# HP-UX only (page size cannot be changed on Linux)
#
def rule_itlb_misses(object):
try:
# --- Validate rule limitations
if object.type != EXECUTABLE_OBJECT \
or object.os_type != HPUX_OS:
return
# --- Define constants
index_factor = 0.5
index_min_limit = 0.01
# --- Retrieve performance data
# First try cpu_metrics tlb data
metrics = object.get_metrics('TLB.L2_INSTRUCTION_TLB_MISSES/KINST.MEAN')
if metrics:
percent_misses = 100.0 * (metrics[0] / 1000.0)
else:
# Next try itlb_miss data
if (object.pmu_type == ITANIUM2_PMU) or
(object.pmu_type == MONTECITO_PMU):
metrics = object.get_metrics('ITLB_MISSES_FETCH.L1ITLB', 'L1I_READS')
if metrics is None:
return
(itlb_misses, itlb_reads) = metrics
percent_misses = 100.0 * float(itlb_misses) / float(itlb_reads)
# --- Test for potential performance problem and generate advice
index = percent_misses * index_factor
if index > index_min_limit:
object.advice(index, MEMORY_ADVICE,
'itlb misses due to small text pages',
'The "+pi" link option controls the text page size.',
'Try using the "chatr +pi" command on the executable. For '
'example:\n'
' chatr +pi 4M %s\n'
'Then remeasure its itlb miss rate with:\n'
' caliper itlb' % object.name,
'When the text (code) area of a program is large relative '
'to the page size and many functions are not close to '
'their callers, performance can be lost due to the '
'handling of itlb misses.')
except:
pass
18 Overview: HP Caliper Advisor and Analysis Rules