diff options
Diffstat (limited to 'systrace/catapult/systrace/systrace/tracing_agents/atrace_agent.py')
-rw-r--r-- | systrace/catapult/systrace/systrace/tracing_agents/atrace_agent.py | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/systrace/catapult/systrace/systrace/tracing_agents/atrace_agent.py b/systrace/catapult/systrace/systrace/tracing_agents/atrace_agent.py index 47ed3fa..caf78f4 100644 --- a/systrace/catapult/systrace/systrace/tracing_agents/atrace_agent.py +++ b/systrace/catapult/systrace/systrace/tracing_agents/atrace_agent.py @@ -4,12 +4,13 @@ import optparse import platform -import py_utils import re import sys import threading import zlib +import py_utils + from devil.android import device_utils from devil.android.sdk import version_codes from py_trace_event import trace_time as trace_time_module @@ -139,6 +140,11 @@ def _construct_atrace_args(config, categories): if (config.trace_buf_size is not None) and (config.trace_buf_size > 0): atrace_args.extend(['-b', str(config.trace_buf_size)]) + elif 'webview' in categories and 'sched' in categories: + # https://crbug.com/814330: webview_startup sometimes exceeds the buffer + # limit, so doubling this. + atrace_args.extend(['-b', '8192']) + elif 'sched' in categories: # 'sched' is a high-volume tag, double the default buffer size # to accommodate that @@ -235,19 +241,28 @@ class AtraceAgent(tracing_agents.TracingAgent): def _stop_collect_trace(self): """Stops atrace. - Note that prior to Api 23, --async-stop may not actually stop tracing. - Thus, this uses a fallback method of running a zero-length synchronous - trace if tracing is still on.""" - result = self._device_utils.RunShellCommand( - self._tracer_args + ['--async_stop'], raw_output=True, - large_output=True, check_return=True, timeout=ADB_LARGE_OUTPUT_TIMEOUT) - is_trace_enabled_file = '/sys/kernel/debug/tracing/tracing_on' - + Note that prior to Api 23, --async-stop isn't working correctly. It + doesn't stop tracing and clears trace buffer before dumping it rendering + results unusable.""" if self._device_sdk_version < version_codes.MARSHMALLOW: - if int(self._device_utils.ReadFile(is_trace_enabled_file)): - # tracing was incorrectly left on, disable it - self._device_utils.RunShellCommand( - self._tracer_args + ['-t 0'], check_return=True) + is_trace_enabled_file = '/sys/kernel/debug/tracing/tracing_on' + # Stop tracing first so new data won't arrive while dump is performed (it + # may take a non-trivial time and tracing buffer may overflow). + self._device_utils.WriteFile(is_trace_enabled_file, '0') + result = self._device_utils.RunShellCommand( + self._tracer_args + ['--async_dump'], raw_output=True, + large_output=True, check_return=True, + timeout=ADB_LARGE_OUTPUT_TIMEOUT) + # Run synchronous tracing for 0 seconds to stop tracing, clear buffers + # and other state. + self._device_utils.RunShellCommand( + self._tracer_args + ['-t 0'], check_return=True) + else: + # On M+ --async_stop does everything necessary + result = self._device_utils.RunShellCommand( + self._tracer_args + ['--async_stop'], raw_output=True, + large_output=True, check_return=True, + timeout=ADB_LARGE_OUTPUT_TIMEOUT) return result |