Skip to content

Commit

Permalink
abbreviate uncore event names to shorten the length of the arguments …
Browse files Browse the repository at this point in the history
…on the perf command line (#102)
  • Loading branch information
harp-intel authored Nov 26, 2024
1 parent 4da2d5f commit bc95c81
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
35 changes: 35 additions & 0 deletions cmd/metrics/event_defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ func LoadEventGroups(eventDefinitionOverridePath string, metadata Metadata) (gro
if event, err = parseEventDefinition(line[:len(line)-1]); err != nil {
return
}
// abbreviate the event name to shorten the eventual perf stat command line
event.Name = abbreviateEventName(event.Name)
event.Raw = abbreviateEventName(event.Raw)
if isCollectableEvent(event, metadata) {
group = append(group, event)
} else {
Expand Down Expand Up @@ -90,6 +93,38 @@ func LoadEventGroups(eventDefinitionOverridePath string, metadata Metadata) (gro
return
}

// abbreviateEventName replaces long event names with abbreviations to reduce the length of the perf command.
// focus is on uncore events because they are repeated for each uncore device
func abbreviateEventName(event string) string {
// Abbreviations must be unique and in order. And, if replacing UNC_*, the abbreviation must begin with "UNC" because this is how we identify uncore events when collapsing them.
var abbreviations = [][]string{
{"UNC_CHA_TOR_INSERTS", "UNCCTI"},
{"UNC_CHA_TOR_OCCUPANCY", "UNCCTO"},
{"UNC_CHA_CLOCKTICKS", "UNCCCT"},
{"UNC_M_CAS_COUNT_SCH", "UNCMCC"},
{"IA_MISS_DRD_REMOTE", "IMDR"},
{"IA_MISS_DRD_LOCAL", "IMDL"},
{"IA_MISS_LLCPREFDATA", "IMLP"},
{"IA_MISS_LLCPREFRFO", "IMLR"},
{"IA_MISS_DRD_PREF_LOCAL", "IMDPL"},
{"IA_MISS_DRD_PREF_REMOTE", "IMDRP"},
{"IA_MISS_CRD_PREF", "IMCP"},
{"IA_MISS_RFO_PREF", "IMRP"},
{"IA_MISS_RFO", "IMRF"},
{"IA_MISS_CRD", "IMC"},
{"IA_MISS_DRD", "IMD"},
{"IO_PCIRDCUR", "IPCI"},
{"IO_ITOMCACHENEAR", "IITN"},
{"IO_ITOM", "IITO"},
{"IMD_OPT", "IMDO"},
}
// if an abbreviation key is found in the event, replace the matching portion of the event with the abbreviation
for _, abbr := range abbreviations {
event = strings.Replace(event, abbr[0], abbr[1], -1)
}
return event
}

// isCollectableEvent confirms if given event can be collected on the platform
func isCollectableEvent(event EventDefinition, metadata Metadata) bool {
// fixed-counter TMA
Expand Down
3 changes: 3 additions & 0 deletions cmd/metrics/metric_defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ func ConfigureMetrics(metrics []MetricDefinition, evaluatorFunctions map[string]
metrics[metricIdx].Expression = strings.ReplaceAll(metrics[metricIdx].Expression, "[SOCKET_COUNT]", socketCount)
metrics[metricIdx].Expression = strings.ReplaceAll(metrics[metricIdx].Expression, "[HYPERTHREADING_ON]", hyperThreadingOn)
metrics[metricIdx].Expression = strings.ReplaceAll(metrics[metricIdx].Expression, "[CONST_THREAD_COUNT]", threadsPerCore)
// abbreviate event names
metrics[metricIdx].Expression = abbreviateEventName(metrics[metricIdx].Expression)
metrics[metricIdx].ExpressionTxn = abbreviateEventName(metrics[metricIdx].ExpressionTxn)
// get a list of the variables in the expression
metrics[metricIdx].Variables = make(map[string]int)
expressionIdx := 0
Expand Down

0 comments on commit bc95c81

Please sign in to comment.