-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add generic perf trace instrument #388
Conversation
Introduce a class allowing to programmatically generate CLI commands in a clear, reliable and robust way for any calling code manipulating raw command strings.
Introduce a perf collector that is more generic than the previous one and which is expected to be able to handle all potential calls to perf (irrespective of the subcommand, flags, options or arguments being used).
kwflags_sep='=', | ||
end_of_options='--', | ||
**parameters) | ||
if 'stat'in parameters['command']: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space before in
for label, command in self.post_commands.items(): | ||
self.execute(str(command), label) | ||
|
||
def _target_runnable_command(self, command, label=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Private" methods should go after the "normal" methods.
if sys.version_info >= (3, 0): | ||
from shlex import quote | ||
else: | ||
from pipes import quote |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implies that compatibility with Python2.7 is attempted to be retained however is not present elsewhere in this PR. Is this aimed to be merged before the next release aka supporting Python 2.7 or to be held until after support has been dropped?
See the comment on ARM-software/workload-automation#979. |
As discussed in #382, this PR modifies the
perf
trace instrument so that it accepts anyperf
command. It implements the back-end of ARM-software/workload-automation#979 and requires fix #387 to avoid #386. It is arguably simple as it receives the commands to run as strings (prepending the path toperf
) and runs them "at the right time".Based on the subcommands
perf
currently has, it looks like these can be placed in 3 categories:commands
): used to trace/measure some system properties (stat
,record
,mem
,sched
,kmem
,kvm
,c2c
, ...);post_commands
): used to process a trace file from a "measuring" command (report
,script
,timechart
,annotate,
c2c report`, ...);pre_commands
): used to configure the system or get general information (list
,config
,buildid-list
,help
, ...)Therefore, we take 3 dictionaries of commands that are run in order (
pre_
, thencommands
, thenpost_
) in accord with these definitions. I'm still not perfectly sure about "when" in the WA/devlib process these are to be run, though. Please check that.The reason why we have dictionaries for commands (instead of lists) is that the keys can act as a label which seemed to be a desired feature of the previous implementation. As we have multiple dictionaries, a same label can appear multiple times (i.e. as a key in more than a single dictionary). In that case, it makes sense to "group" these commands in their own "execution lane" e.g. a
record
and its correspondingreport
. Maybe, these labels could be used as directory names on the target and then on the host, once having been extracted(?) For example, commands within the same label would "see" the same files (as they would be in the same subfolder) while commands with different labels wouldn't and would therefore be able to re-use the same filenames. A similar approach with respect to the filename would be to prepend/inject/append the label to the filename.The
Command
class is implemented to be used by the corresponding WAperf
instrument when generating theperf
commands passed to the devlibPerfCollector
. I thought it would make sense to have that class in devlib instead of WA. See the front-end PR for a description of the constructor parameters.The
get_trace
hasn't been implemented yet. If we're going with a function that extracts oneoutfile
at a time, the caller (WA) will have to keep track of which files are generated by which commands (e.g. thestdout
,stderr
,perf.data
, ...) which is hard to do. Another approach might be to extract a pull a complete folder from the target (e.g./sdcard/devlib-target/perf
) in whichperf
would have run. This decision is also influenced by whether labels are used as subfolders or not.Parsing of the output(s) is the responsibility of WA and won't be done here.
Please note that the proposed implementation is not an in-place replacement for the previous implementation of
PerfCollector
. Therefore, the previous implementation has been moved toperf_stat
, should be deprecated (not sure what the best way to do that is) and should eventually be removed.TODO:
pre_
,commands
,post_
in the WA/devlib flow;DeprecatePerfStatCollector
PerfCollector
(what is expected?)