aboutsummaryrefslogtreecommitdiff
path: root/crosperf/results_cache.py
diff options
context:
space:
mode:
authorZhizhou Yang <zhizhouy@google.com>2019-04-10 14:04:05 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-04-18 19:52:03 -0700
commitced8957f7a858d5cca66352522e916705f004944 (patch)
tree7777bb88cd76c4d6c97442b8cbe91c39754042cd /crosperf/results_cache.py
parent5ed02e0990d636f4220ac3259cfe541a296275b6 (diff)
downloadtoolchain-utils-ced8957f7a858d5cca66352522e916705f004944.tar.gz
crosperf: generate perf report with correct debug files
This patch fixes the issue in chromium:946588. This patch makes perf report no longer use hard code debug directories. There are several different situations: 1) When running tests on a downloaded image, it will download debug.tgz from gs, extract it to debug_files in /tmp. Options --symfs and --vmlinux will depend on this directory, and throw a warning to user that --kallsyms cannot be applied. 2) If running with downloaded image and debug.tgz could not work, then we will try to use local build, but give user a warning that it may not match real symbols well. 3) When running tests with local build, try to find debug info from /build/$board directory. Thus, this patch added a new field in label, called 'debug_path', if this is manually set in experiment file, then crosperf will directly use the location. Downloading of debug.tgz will only happen when perf_args is set in global settings. TEST=Passed all unit tests, tested with eve and sand. BUG=chromium:946588 Change-Id: I7f35d1216d912c8526d5501748f951face1273aa Reviewed-on: https://chromium-review.googlesource.com/1561780 Commit-Ready: Zhizhou Yang <zhizhouy@google.com> Tested-by: Zhizhou Yang <zhizhouy@google.com> Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Diffstat (limited to 'crosperf/results_cache.py')
-rw-r--r--crosperf/results_cache.py52
1 files changed, 43 insertions, 9 deletions
diff --git a/crosperf/results_cache.py b/crosperf/results_cache.py
index 39c127bf..bef78cb4 100644
--- a/crosperf/results_cache.py
+++ b/crosperf/results_cache.py
@@ -266,6 +266,18 @@ class Result(object):
self.FindFilesInResultsDir('-name results-chart.json').splitlines()
return result
+ def _CheckDebugPath(self, option, path):
+ relative_path = path[1:]
+ out_chroot_path = os.path.join(self.chromeos_root, 'chroot', relative_path)
+ if os.path.exists(out_chroot_path):
+ if option == 'kallsyms':
+ path = os.path.join(path, 'System.map-*')
+ return '--' + option + ' ' + path
+ else:
+ print('** WARNING **: --%s option not applied, %s does not exist' %
+ (option, out_chroot_path))
+ return ''
+
def GeneratePerfReportFiles(self):
perf_report_files = []
for perf_data_file in self.perf_data_files:
@@ -285,15 +297,37 @@ class Result(object):
if os.path.exists(perf_path):
perf_file = '/usr/bin/perf'
- command = ('%s report '
- '-n '
- '--symfs /build/%s '
- '--vmlinux /build/%s/usr/lib/debug/boot/vmlinux '
- '--kallsyms /build/%s/boot/System.map-* '
- '-i %s --stdio '
- '> %s' % (perf_file, self.board, self.board, self.board,
- chroot_perf_data_file, chroot_perf_report_file))
- self.ce.ChrootRunCommand(self.chromeos_root, command)
+ debug_path = self.label.debug_path
+
+ if debug_path:
+ symfs = '--symfs ' + debug_path
+ vmlinux = '--vmlinux ' + os.path.join(debug_path, 'boot', 'vmlinux')
+ kallsyms = ''
+ print('** WARNING **: --kallsyms option not applied, no System.map-* '
+ 'for downloaded image.')
+ else:
+ if self.label.image_type != 'local':
+ print('** WARNING **: Using local debug info in /build, this may '
+ 'not match the downloaded image.')
+ build_path = os.path.join('/build', self.board)
+ symfs = self._CheckDebugPath('symfs', build_path)
+ vmlinux_path = os.path.join(build_path, 'usr/lib/debug/boot/vmlinux')
+ vmlinux = self._CheckDebugPath('vmlinux', vmlinux_path)
+ kallsyms_path = os.path.join(build_path, 'boot')
+ kallsyms = self._CheckDebugPath('kallsyms', kallsyms_path)
+
+ command = ('%s report -n %s %s %s -i %s --stdio > %s' %
+ (perf_file, symfs, vmlinux, kallsyms, chroot_perf_data_file,
+ chroot_perf_report_file))
+ if self.log_level != 'verbose':
+ self._logger.LogOutput('Generating perf report...\nCMD: %s' % command)
+ exit_code = self.ce.ChrootRunCommand(self.chromeos_root, command)
+ if exit_code == 0:
+ if self.log_level != 'verbose':
+ self._logger.LogOutput('Perf report generated successfully.')
+ else:
+ raise RuntimeError(
+ 'Perf report not generated correctly. CMD: %s' % command)
# Add a keyval to the dictionary for the events captured.
perf_report_files.append(