Skip to contentSkip to conversation

perf hist: Improve srcfile sort key performance (really)

PATCH Applied Namhyung Kim 2 participants 2 messages Mar 23, 2023 perf events

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH 1/1 perf hist: Improve srcfile sort key performance (really)

The earlier commit f0cdde28fecc ("perf hist: Improve srcfile sort key performance") updated the srcfile logic but missed to change the ->cmp() callback which is called for every sample. It should use the same logic like in the srcline to speed up the processing because it'd return the same information repeatedly for the same address. The real processing will be done in sort__srcfile_collapse().

Fixes pf0cdde28fecc ("perf hist: Improve srcfile sort key performance")
---
 tools/perf/util/sort.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
tools/perf/util/sort.c +1 -6
index e11e68ecf0a2..2b5cc8e4aa6e 100644
@@ -657,12 +657,7 @@ static char *hist_entry__get_srcfile(struct hist_entry *e)
 static int64_t
 sort__srcfile_cmp(struct hist_entry *left, struct hist_entry *right)
 {
-	if (!left->srcfile)
-		left->srcfile = hist_entry__get_srcfile(left);
-	if (!right->srcfile)
-		right->srcfile = hist_entry__get_srcfile(right);
-
-	return strcmp(right->srcfile, left->srcfile);
+	return sort__srcline_cmp(left, right);
 }
 
 static int64_t
Signature · 1 line
2.40.0.rc1.284.g88254d51c5-goog
maintainer Applied
#1 lore raw

Em Wed, Mar 22, 2023 at 07:50:05PM -0700, Namhyung Kim escreveu:

Quoted 6 lines

The earlier commit f0cdde28fecc ("perf hist: Improve srcfile sort key performance") updated the srcfile logic but missed to change the ->cmp() callback which is called for every sample. It should use the same logic like in the srcline to speed up the processing because it'd return the same information repeatedly for the same address. The real processing will be done in sort__srcfile_collapse().

Thanks, applied.

- Arnaldo

Quoted 27 lines
Fixes pf0cdde28fecc ("perf hist: Improve srcfile sort key performance")
---
 tools/perf/util/sort.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
tools/perf/util/sort.c +1 -6
index e11e68ecf0a2..2b5cc8e4aa6e 100644
@@ -657,12 +657,7 @@ static char *hist_entry__get_srcfile(struct hist_entry *e)
 static int64_t
 sort__srcfile_cmp(struct hist_entry *left, struct hist_entry *right)
 {
-	if (!left->srcfile)
-		left->srcfile = hist_entry__get_srcfile(left);
-	if (!right->srcfile)
-		right->srcfile = hist_entry__get_srcfile(right);
-
-	return strcmp(right->srcfile, left->srcfile);
+	return sort__srcline_cmp(left, right);
 }
 
 static int64_t
Signature · 1 line
2.40.0.rc1.284.g88254d51c5-goog
Signature · 1 line
- Arnaldo