Skip to contentSkip to conversation

perf/test: Speed up test case perf annotate basic tests

PATCH Applied Thomas Richter 3 participants 4 messages Sep 17, 2024 – Sep 27, 2024 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf/test: Speed up test case perf annotate basic tests

perf test 70 takes a long time. One culprit is the output of command perf annotate. Per default enabled are
- demangle symbol names
- interleave source code with assembly code.
Disable demangle of symbols and abort the annotation after the first 250 lines.

This speeds up the test case considerable, for example on s390:

Output before:

 # time  perf test 70
 70: perf annotate basic tests             : Ok
 .....
 real   2m7.467s
 user   1m26.869s
 sys    0m34.086s
 #

Output after:

 # time perf test 70
 70: perf annotate basic tests             : Ok
 real   0m3.341s
 user   0m1.606s
 sys    0m0.362s

#

Cc Heiko Carstens <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Alexander Gordeev <[email protected]>
---
 tools/perf/tests/shell/annotate.sh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
tools/perf/tests/shell/annotate.sh +5 -5
index b072d9b97387..b28cd95b1d83 100755
@@ -43,7 +43,7 @@ test_basic() {
   fi
 
   # Generate the annotated output file
-  perf annotate -i "${perfdata}" --stdio 2> /dev/null > "${perfout}"
+  perf annotate --no-demangle -i "${perfdata}" --stdio 2> /dev/null | head -250 > "${perfout}"
 
   # check if it has the target symbol
   if ! grep "${testsym}" "${perfout}"
@@ -62,8 +62,8 @@ test_basic() {
   fi
 
   # check again with a target symbol name
-  if ! perf annotate -i "${perfdata}" "${testsym}" 2> /dev/null | \
-	  grep -m 3 "${disasm_regex}"
+  if ! perf annotate --no-demangle -i "${perfdata}" "${testsym}" 2> /dev/null | \
+	  head -250 | grep -m 3 "${disasm_regex}"
   then
     echo "Basic annotate [Failed: missing disasm output when specifying the target symbol]"
     err=1
@@ -71,8 +71,8 @@ test_basic() {
   fi
 
   # check one more with external objdump tool (forced by --objdump option)
-  if ! perf annotate -i "${perfdata}" --objdump=objdump 2> /dev/null | \
-	  grep -m 3 "${disasm_regex}"
+  if ! perf annotate --no-demangle -i "${perfdata}" --objdump=objdump 2> /dev/null | \
+	  head -250 | grep -m 3 "${disasm_regex}"
   then
     echo "Basic annotate [Failed: missing disasm output from non default disassembler (using --objdump)]"
     err=1
Signature · 1 line
2.46.0
reviewer
#1 lore raw
Quoted 72 lines · Thomas Richter

perf test 70 takes a long time. One culprit is the output of command perf annotate. Per default enabled are
- demangle symbol names
- interleave source code with assembly code.
Disable demangle of symbols and abort the annotation after the first 250 lines.

This speeds up the test case considerable, for example on s390:

Output before:

  # time  perf test 70
  70: perf annotate basic tests             : Ok
  .....
  real   2m7.467s
  user   1m26.869s
  sys    0m34.086s
  #

Output after:

  # time perf test 70
  70: perf annotate basic tests             : Ok
  real   0m3.341s
  user   0m1.606s
  sys    0m0.362s

#

Cc Heiko Carstens <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Alexander Gordeev <[email protected]>
---
  tools/perf/tests/shell/annotate.sh | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
tools/perf/tests/shell/annotate.sh +5 -5
index b072d9b97387..b28cd95b1d83 100755
@@ -43,7 +43,7 @@ test_basic() {
    fi
 
    # Generate the annotated output file
-  perf annotate -i "${perfdata}" --stdio 2> /dev/null > "${perfout}"
+  perf annotate --no-demangle -i "${perfdata}" --stdio 2> /dev/null | head -250 > "${perfout}"
 
    # check if it has the target symbol
    if ! grep "${testsym}" "${perfout}"
@@ -62,8 +62,8 @@ test_basic() {
    fi
 
    # check again with a target symbol name
-  if ! perf annotate -i "${perfdata}" "${testsym}" 2> /dev/null | \
-	  grep -m 3 "${disasm_regex}"
+  if ! perf annotate --no-demangle -i "${perfdata}" "${testsym}" 2> /dev/null | \
+	  head -250 | grep -m 3 "${disasm_regex}"
    then
      echo "Basic annotate [Failed: missing disasm output when specifying the target symbol]"
      err=1
@@ -71,8 +71,8 @@ test_basic() {
    fi
 
    # check one more with external objdump tool (forced by --objdump option)
-  if ! perf annotate -i "${perfdata}" --objdump=objdump 2> /dev/null | \
-	  grep -m 3 "${disasm_regex}"
+  if ! perf annotate --no-demangle -i "${perfdata}" --objdump=objdump 2> /dev/null | \
+	  head -250 | grep -m 3 "${disasm_regex}"
    then
      echo "Basic annotate [Failed: missing disasm output from non default disassembler (using --objdump)]"
      err=1
reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Thomas Richter
Quoted 19 lines · Thomas Richter

perf test 70 takes a long time. One culprit is the output of command perf annotate. Per default enabled are
- demangle symbol names
- interleave source code with assembly code.
Disable demangle of symbols and abort the annotation after the first 250 lines.

This speeds up the test case considerable, for example on s390:

Output before:

  # time  perf test 70
  70: perf annotate basic tests             : Ok
  .....
  real   2m7.467s
  user   1m26.869s
  sys    0m34.086s
  #
Quoted 9 lines

Output after:

  # time perf test 70
  70: perf annotate basic tests             : Ok
  real   0m3.341s
  user   0m1.606s
  sys    0m0.362s

#

Interesting that there is such a big difference, I only measured 4s vs 14s without the patch.

Either way it's slightly faster now:

maintainer Applied
#3 lore raw
In reply to Thomas Richter
Quoted 8 lines · Thomas Richter

perf test 70 takes a long time. One culprit is the output of command perf annotate. Per default enabled are
- demangle symbol names
- interleave source code with assembly code.
Disable demangle of symbols and abort the annotation after the first 250 lines.

[...]

Applied to perf-tools-next, thanks!

Best regards,
Namhyung