Skip to contentSkip to conversation

perf report: Get rid of unnecessary comm collapsing

PATCH New Namhyung Kim 1 participant 1 message Feb 11 perf events

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH 1/1 perf report: Get rid of unnecessary comm collapsing

The sort_entry->collapse() callback is to merge related hist entries. It's called in hists__collapse_resort() after processing samples using the ->cmp() callback first. The idea was to speed up processing with lighter-weight operation in ->cmp() and do heavier one in ->collapse().

Note that ->cmp() will be called for every sample, but ->collapse() will be called for each hist entry which is pre-processed already. So it's meaningless to have ->collapse() if it's the same as ->cmp().

The 'comm' sort key used to compare 'tid' in ->cmp() and strcmp() in the collapse callback. Then commit fedd63d3cdc9004d ("perf tools: Compare hists comm by addresses") added comm_str and changed it to compare the pointer values. Later, commit 2f15bd8c6c6e80f1 ("perf tools: Fix "Command" sort_entry's cmp and collapse function") changed to compare
trings.

Now 'comm' sort key compares the string from the beginning so there's no point to keep the collapse callback. This will get rid of unnecessary processing in hists__collapse_resort(). It'd give a little speedup on large data files with a lot of threads. But I didn't see it actually from my quick testing.

Cc Frederic Weisbecker <[email protected]>
---
 tools/perf/util/sort.c | 7 -------
 1 file changed, 7 deletions(-)
tools/perf/util/sort.c +0 -7
index 42d5cd7ef4e23960..66c45f450e5101e5 100644
@@ -237,12 +237,6 @@ sort__comm_cmp(struct hist_entry *left, struct hist_entry *right)
 	return strcmp(comm__str(right->comm), comm__str(left->comm));
 }
 
-static int64_t
-sort__comm_collapse(struct hist_entry *left, struct hist_entry *right)
-{
-	return strcmp(comm__str(right->comm), comm__str(left->comm));
-}
-
 static int64_t
 sort__comm_sort(struct hist_entry *left, struct hist_entry *right)
 {
@@ -258,7 +252,6 @@ static int hist_entry__comm_snprintf(struct hist_entry *he, char *bf,
 struct sort_entry sort_comm = {
 	.se_header	= "Command",
 	.se_cmp		= sort__comm_cmp,
-	.se_collapse	= sort__comm_collapse,
 	.se_sort	= sort__comm_sort,
 	.se_snprintf	= hist_entry__comm_snprintf,
 	.se_filter	= hist_entry__thread_filter,
Signature · 1 line
2.53.0.239.g8d8fc8a987-goog