Skip to content
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

Closed
wants to merge 6 commits into from

Conversation

ptosi
Copy link
Contributor

@ptosi ptosi commented May 15, 2019

As discussed in #382, this PR modifies the perf trace instrument so that it accepts any perf 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 to perf) and runs them "at the right time".

Based on the subcommands perf currently has, it looks like these can be placed in 3 categories:

  • The "measuring" commands (commands): used to trace/measure some system properties (stat, record, mem, sched, kmem, kvm, c2c, ...);
  • The "reporting" commands (post_commands): used to process a trace file from a "measuring" command (report, script, timechart, annotate, c2c report`, ...);
  • The "information" and "configuration" commands (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_, then commands, then post_) 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 corresponding report. 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 WA perf instrument when generating the perf commands passed to the devlib PerfCollector. 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 one outfile at a time, the caller (WA) will have to keep track of which files are generated by which commands (e.g. the stdout, 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 which perf 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 to perf_stat, should be deprecated (not sure what the best way to do that is) and should eventually be removed.

TODO:

  • Check the location of execution of pre_, commands, post_ in the WA/devlib flow;
  • Deprecate PerfStatCollector
  • Decide how labels are used on the device
  • Document PerfCollector (what is expected?)
  • Trace extraction (per file? ...)

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).
@ptosi ptosi changed the title [RFC] Add generic perf trace instrument Add generic perf trace instrument Jun 25, 2019
kwflags_sep='=',
end_of_options='--',
**parameters)
if 'stat'in parameters['command']:
Copy link
Collaborator

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):
Copy link
Collaborator

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
Copy link
Collaborator

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?

@ptosi
Copy link
Contributor Author

ptosi commented Jul 9, 2019

See the comment on ARM-software/workload-automation#979.

@ptosi ptosi closed this Jul 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants