Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

abbreviate uncore event names to shorten the length of the arguments on the perf command line #102

Merged
merged 6 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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