From 4f8b7e9f59070301cc975605e7df2c2b74036739 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Thu, 24 Mar 2016 14:48:13 +0000 Subject: [PATCH 1/2] trace-cmd: updating sched_switch parser to handle both formats. Depending on the kernel, sched_switch events may be formatted one of two different ways in the text output. Previously, we've only handled the "old" format. This commit updates the parser to handle the new format as well. --- wlauto/utils/trace_cmd.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/wlauto/utils/trace_cmd.py b/wlauto/utils/trace_cmd.py index 6c64c72d..37ce1fb9 100644 --- a/wlauto/utils/trace_cmd.py +++ b/wlauto/utils/trace_cmd.py @@ -173,6 +173,24 @@ def regex_body_parser(regex, flags=0): return regex_parser_func +def sched_switch_parser(event, text): + """ + Sched switch output may be presented in a couple of different formats. One is handled + by a regex. The other format can *almost* be handled by the default parser, if it + weren't for the ``==>`` that appers in the middle. + """ + if text.count('=') == 2: # old format + regex = re.compile( + r'(?P\S.*):(?P\d+) \[(?P\d+)\] (?P\S+)' + r' ==> ' + r'(?P\S.*):(?P\d+) \[(?P\d+)\]' + ) + parser_func = regex_body_parser(regex) + return parser_func(event, text) + else: # three are more than two "=" -- new format + return default_body_parser(event, text.replace('==>', '')) + + # Maps event onto the corresponding parser for its body text. A parser may be # a callable with signature # @@ -182,11 +200,7 @@ def regex_body_parser(regex, flags=0): # regex). In case of a string/regex, its named groups will be used to populate # the event's attributes. EVENT_PARSER_MAP = { - 'sched_switch': re.compile( - r'(?P\S.*):(?P\d+) \[(?P\d+)\] (?P\S+)' - r' ==> ' - r'(?P\S.*):(?P\d+) \[(?P\d+)\]' - ), + 'sched_switch': sched_switch_parser, } TRACE_EVENT_REGEX = re.compile(r'^\s+(?P\S+.*?\S+)\s+\[(?P\d+)\]\s+(?P[\d.]+):\s+' From 107e8414bb8300b7e5d6a4f89f7af5d49b4cad3f Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Thu, 24 Mar 2016 16:30:58 +0000 Subject: [PATCH 2/2] trace-cmd: set a minimum bound on trace pull timeout The timeout for the pulling the trace file after the run is being set based on the time for which the trace was collected. For workloads with short execution time, but large number of events, the resulting timeout might be too short. To deal with this, do not let the timout be shorter than 1 minute. --- wlauto/instrumentation/trace_cmd/__init__.py | 2 ++ wlauto/utils/trace_cmd.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/wlauto/instrumentation/trace_cmd/__init__.py b/wlauto/instrumentation/trace_cmd/__init__.py index 47296a80..b9c69814 100644 --- a/wlauto/instrumentation/trace_cmd/__init__.py +++ b/wlauto/instrumentation/trace_cmd/__init__.py @@ -233,6 +233,8 @@ class TraceCmdInstrument(Instrument): # Therefore timout for the pull command must also be adjusted # accordingly. self._pull_timeout = (self.stop_time - self.start_time) # pylint: disable=attribute-defined-outside-init + if self._pull_timeout < 60: + self._pull_timeout = 60 self.device.pull_file(self.output_file, context.output_directory, timeout=self._pull_timeout) context.add_iteration_artifact('bintrace', OUTPUT_TRACE_FILE, kind='data', description='trace-cmd generated ftrace dump.') diff --git a/wlauto/utils/trace_cmd.py b/wlauto/utils/trace_cmd.py index 37ce1fb9..1fbd627c 100644 --- a/wlauto/utils/trace_cmd.py +++ b/wlauto/utils/trace_cmd.py @@ -177,7 +177,7 @@ def sched_switch_parser(event, text): """ Sched switch output may be presented in a couple of different formats. One is handled by a regex. The other format can *almost* be handled by the default parser, if it - weren't for the ``==>`` that appers in the middle. + weren't for the ``==>`` that appears in the middle. """ if text.count('=') == 2: # old format regex = re.compile( @@ -187,7 +187,7 @@ def sched_switch_parser(event, text): ) parser_func = regex_body_parser(regex) return parser_func(event, text) - else: # three are more than two "=" -- new format + else: # there are more than two "=" -- new format return default_body_parser(event, text.replace('==>', ''))