Commit 7bddaa0d authored by pasko's avatar pasko Committed by Commit bot

Perfhost for ubuntu trusty

Review URL: https://codereview.chromium.org/474933005

Cr-Commit-Position: refs/heads/master@{#292930}
parent 2997d2df
...@@ -164,7 +164,8 @@ class PerfProfilerController(controllers.BaseController): ...@@ -164,7 +164,8 @@ class PerfProfilerController(controllers.BaseController):
symfs_dir, symfs_dir,
required_libs, required_libs,
use_symlinks=False) use_symlinks=False)
perfhost_path = support_binaries.FindPath('perfhost', 'linux') perfhost_path = support_binaries.FindPath(
android_profiling_helper.GetPerfhostName(), 'linux')
ui.PrintMessage('\nNote: to view the profile in perf, run:') ui.PrintMessage('\nNote: to view the profile in perf, run:')
ui.PrintMessage(' ' + self._GetInteractivePerfCommand(perfhost_path, ui.PrintMessage(' ' + self._GetInteractivePerfCommand(perfhost_path,
......
...@@ -12,3 +12,23 @@ IEDriverServer binary: ...@@ -12,3 +12,23 @@ IEDriverServer binary:
ipfw and ipfw_mod.ko: ipfw and ipfw_mod.ko:
Version 20120812 Version 20120812
perfhost_trusty:
Built from kernel sources following this method:
shell> git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux
shell> cd linux
shell> git checkout v3.13
shell> cd tools/perf
shell> make
shell> ./perf test
Tests should mostly pass, except a few:
1: vmlinux symtab matches kallsyms : FAILED!
2: detect open syscall event : FAILED!
3: detect open syscall event on all cpus : FAILED!
4: read samples using the mmap interface : FAILED!
5: parse events tests : FAILED!
[snip]
11: Check parsing of sched tracepoints fields : FAILED!
12: Generate and check syscalls:sys_enter_open event fields: FAILED!
21: Test object code reading :[kernel.kallsyms] ... FAILED!
shell> mv perf perfhost_trusty
ddb9b3508fe3e8b056071fc7c3d069d13635d371
\ No newline at end of file
dabf42e27eb92f84eeb467436b06cf26e9a5a067
\ No newline at end of file
...@@ -15,6 +15,12 @@ from telemetry.util import cloud_storage ...@@ -15,6 +15,12 @@ from telemetry.util import cloud_storage
from telemetry.util import support_binaries from telemetry.util import support_binaries
_POSSIBLE_PERFHOST_APPLICATIONS = [
'perfhost_precise',
'perfhost_trusty',
]
class LinuxPlatformBackend( class LinuxPlatformBackend(
posix_platform_backend.PosixPlatformBackend, posix_platform_backend.PosixPlatformBackend,
linux_based_platform_backend.LinuxBasedPlatformBackend): linux_based_platform_backend.LinuxBasedPlatformBackend):
...@@ -74,9 +80,9 @@ class LinuxPlatformBackend( ...@@ -74,9 +80,9 @@ class LinuxPlatformBackend(
if application == 'ipfw': if application == 'ipfw':
self._InstallIpfw() self._InstallIpfw()
elif application == 'avconv': elif application == 'avconv':
self._InstallBinary(application, 'libav-tools') self._InstallBinary(application, fallback_package='libav-tools')
elif application == 'perfhost': elif application in _POSSIBLE_PERFHOST_APPLICATIONS:
self._InstallBinary(application, 'linux-tools') self._InstallBinary(application)
else: else:
raise NotImplementedError( raise NotImplementedError(
'Please teach Telemetry how to install ' + application) 'Please teach Telemetry how to install ' + application)
...@@ -114,6 +120,8 @@ class LinuxPlatformBackend( ...@@ -114,6 +120,8 @@ class LinuxPlatformBackend(
def _InstallBinary(self, bin_name, fallback_package=None): def _InstallBinary(self, bin_name, fallback_package=None):
bin_path = support_binaries.FindPath(bin_name, self.GetOSName()) bin_path = support_binaries.FindPath(bin_name, self.GetOSName())
if not bin_path:
raise Exception('Could not find the binary package %s' % bin_name)
os.environ['PATH'] += os.pathsep + os.path.dirname(bin_path) os.environ['PATH'] += os.pathsep + os.path.dirname(bin_path)
try: try:
...@@ -122,8 +130,8 @@ class LinuxPlatformBackend( ...@@ -122,8 +130,8 @@ class LinuxPlatformBackend(
except cloud_storage.CloudStorageError, e: except cloud_storage.CloudStorageError, e:
logging.error(str(e)) logging.error(str(e))
if fallback_package: if fallback_package:
logging.error('You may proceed by manually installing %s via:\n' raise Exception('You may proceed by manually installing %s via:\n'
'sudo apt-get install %s' % (bin_name, fallback_package)) 'sudo apt-get install %s' %
sys.exit(1) (bin_name, fallback_package))
assert self.CanLaunchApplication(bin_name), 'Failed to install ' + bin_name assert self.CanLaunchApplication(bin_name), 'Failed to install ' + bin_name
...@@ -11,6 +11,8 @@ import re ...@@ -11,6 +11,8 @@ import re
import shutil import shutil
import subprocess import subprocess
from telemetry import decorators
from telemetry.core import platform as telemetry_platform
from telemetry.core import util from telemetry.core import util
from telemetry.core.platform.profiler import android_prebuilt_profiler_helper from telemetry.core.platform.profiler import android_prebuilt_profiler_helper
from telemetry.util import support_binaries from telemetry.util import support_binaries
...@@ -81,6 +83,11 @@ def _FindMatchingUnstrippedLibraryOnHost(device, lib): ...@@ -81,6 +83,11 @@ def _FindMatchingUnstrippedLibraryOnHost(device, lib):
return unstripped_host_lib return unstripped_host_lib
@decorators.Cache
def GetPerfhostName():
return 'perfhost_' + telemetry_platform.GetHostPlatform().GetOSVersionName()
# Ignored directories for libraries that aren't useful for symbolization. # Ignored directories for libraries that aren't useful for symbolization.
_IGNORED_LIB_PATHS = [ _IGNORED_LIB_PATHS = [
'/data/dalvik-cache', '/data/dalvik-cache',
...@@ -98,7 +105,7 @@ def GetRequiredLibrariesForPerfProfile(profile_file): ...@@ -98,7 +105,7 @@ def GetRequiredLibrariesForPerfProfile(profile_file):
A set of required library file names. A set of required library file names.
""" """
with open(os.devnull, 'w') as dev_null: with open(os.devnull, 'w') as dev_null:
perfhost_path = support_binaries.FindPath('perfhost', 'linux') perfhost_path = support_binaries.FindPath(GetPerfhostName(), 'linux')
perf = subprocess.Popen([perfhost_path, 'script', '-i', profile_file], perf = subprocess.Popen([perfhost_path, 'script', '-i', profile_file],
stdout=dev_null, stderr=subprocess.PIPE) stdout=dev_null, stderr=subprocess.PIPE)
_, output = perf.communicate() _, output = perf.communicate()
......
...@@ -10,6 +10,8 @@ import subprocess ...@@ -10,6 +10,8 @@ import subprocess
import sys import sys
import tempfile import tempfile
from pylib.device import device_errors # pylint: disable=F0401
from telemetry.core import platform from telemetry.core import platform
from telemetry.core import util from telemetry.core import util
from telemetry.core.platform import profiler from telemetry.core.platform import profiler
...@@ -52,10 +54,11 @@ def _PrepareHostForPerf(): ...@@ -52,10 +54,11 @@ def _PrepareHostForPerf():
def _InstallPerfHost(): def _InstallPerfHost():
perfhost_name = android_profiling_helper.GetPerfhostName()
host = platform.GetHostPlatform() host = platform.GetHostPlatform()
if not host.CanLaunchApplication('perfhost'): if not host.CanLaunchApplication(perfhost_name):
host.InstallApplication('perfhost') host.InstallApplication(perfhost_name)
return support_binaries.FindPath('perfhost', host.GetOSName()) return support_binaries.FindPath(perfhost_name, 'linux')
class _SingleProcessPerfProfiler(object): class _SingleProcessPerfProfiler(object):
...@@ -100,7 +103,10 @@ class _SingleProcessPerfProfiler(object): ...@@ -100,7 +103,10 @@ class _SingleProcessPerfProfiler(object):
'"--extra-browser-args=--single-process"') '"--extra-browser-args=--single-process"')
if self._is_android: if self._is_android:
device = self._browser_backend.adb.device() device = self._browser_backend.adb.device()
device.KillAll('perf', signum=signal.SIGINT, blocking=True) try:
device.KillAll('perf', signum=signal.SIGINT, blocking=True)
except device_errors.CommandFailedError:
logging.warning('The perf process could not be killed on the device.')
self._proc.send_signal(signal.SIGINT) self._proc.send_signal(signal.SIGINT)
exit_code = self._proc.wait() exit_code = self._proc.wait()
try: try:
...@@ -221,8 +227,8 @@ class PerfProfiler(profiler.Profiler): ...@@ -221,8 +227,8 @@ class PerfProfiler(profiler.Profiler):
with open(os.devnull, 'w') as devnull: with open(os.devnull, 'w') as devnull:
_InstallPerfHost() _InstallPerfHost()
report = subprocess.Popen( report = subprocess.Popen(
['perfhost', 'report', '--show-total-period', '-U', '-t', '^', '-i', [android_profiling_helper.GetPerfhostName(),
file_name], 'report', '--show-total-period', '-U', '-t', '^', '-i', file_name],
stdout=subprocess.PIPE, stderr=devnull).communicate()[0] stdout=subprocess.PIPE, stderr=devnull).communicate()[0]
period_by_function = {} period_by_function = {}
for line in report.split('\n'): for line in report.split('\n'):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment