HP Caliper Advisor Rule Writer Guide
the HP Caliper Advisor, with Annotations” deals with ITLB data from either a
cpu or an itlb HP Caliper run.
• The advice index value should be calculated carefully. It should reflect how likely
a recommended improvement is to actually improve performance. It is better to
be a little pessimistic rather than overstate potential benefits.
• It is more efficient to pre-test for the possible presence of metrics before requesting
them. For example, this code:
if object.pmu_type == ITANIUM2_PMU:
metrics = object.get_metrics(‘CPU_CYCLES’)
elif object.pmu_type == MONTECITO_PMU:
metrics = object.get_metrics(‘CPU_OP_CYCLES.ALL’)
else:
metrics = None
is faster than this code:
metrics = object.get_metrics(‘CPU_CYCLES’)
if metrics is None:
metrics = object.get_metrics(‘CPU_OP_CYCLES.ALL’)
The first block of code is faster because it avoids making get_metrics() calls
that can never be successful, given the processor used.
• Rule functions can be grouped into files using criteria such as: performance area
they deal with (CPU, memory, I/O, and so forth), application type (CPU-intensive,
database, MPI, interactive, and so forth), advice type (metric, explanation,
measurement, improvement), and so on.
Rule files can 'include' other rule files and the infrastructure will ignore duplicate
inclusions of the same file.
• There are two easy ways to (temporarily) disable a rule without deleting its code
or commenting it out.
The first is to change the name of the rule function from rule_xyz to Xrule_xyz.
The Advisor will not invoke the function because it is not named correctly. This
technique works well when testing new rule functions.
The second method works best when you cannot or do not want to physically
change a rule file. In a later rule file (for example, the my_rules file), add a
redefinition of the rule function to replace the earlier definition. For example, to
disable rule_xyz, use this code:
def rule_xyz(object):
pass
The new version of the function will be called, but it does nothing.
• Note that these statements are not equivalent:
metrics = object.get_metrics(‘CPU_CYCLES’, ‘NOPS_RETIRED’)
Additional Tips for Writing Rules 63