Skip to content

Support collecting perf profiles remotely #275

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ config.traditional_output = False
config.single_source = False
if "SSH_AUTH_SOCK" in os.environ:
config.environment["SSH_AUTH_SOCK"] = os.environ["SSH_AUTH_SOCK"]
if not hasattr(config, "remote_host"):
config.remote_host = ""
config.remote_host = lit_config.params.get("remote_host", config.remote_host)
if config.remote_host:
config.test_modules.append("remote")

# Load previous test results so we can skip tests that did not change.
previous_results_file = lit_config.params.get("previous", None)
Expand All @@ -55,3 +50,9 @@ if lit_config.params.get("profile") == "hpmcount":
config.substitutions += [
("%b", os.path.join(config.test_exec_root, "tools")),
]

if not hasattr(config, "remote_host"):
config.remote_host = ""
config.remote_host = lit_config.params.get("remote_host", config.remote_host)
if config.remote_host:
config.test_modules.append("remote")
2 changes: 1 addition & 1 deletion litsupport/modules/profilegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ def mutatePlan(context, plan):
profdatafile = context.executable + ".profdata"
args = ["merge", "-output=%s" % profdatafile] + context.profilefiles
mergecmd = shellcommand.ShellCommand(context.config.llvm_profdata, args)
plan.profilescript += [mergecmd.toCommandline()]
plan.profilecollectscript += [mergecmd.toCommandline()]
8 changes: 6 additions & 2 deletions litsupport/modules/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,18 @@ def mutatePlan(context, plan):
plan.verifyscript = _mutateScript(context, plan.verifyscript)
for name, script in plan.metricscripts.items():
plan.metricscripts[name] = _mutateScript(context, script)
plan.profilescript = _mutateScript(context, plan.profilescript)

# Merging profile data should happen on the host because that is where
# the toolchain resides, however we have to retrieve the profile data
# from the device first, add commands for that to the profile script.
for path in plan.profile_files:
profile_files = plan.profile_files
if context.profilefile:
profile_files += [context.profilefile]
for path in profile_files:
assert os.path.isabs(path)
command = "scp %s:%s %s" % (context.config.remote_host, path, path)
plan.profilescript.insert(0, command)
plan.profilecollectscript.insert(0, command)

assert context.read_result_file is testplan.default_read_result_file
context.read_result_file = remote_read_result_file
9 changes: 9 additions & 0 deletions litsupport/testplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self):
self.preparescript = []
self.profile_files = []
self.profilescript = []
self.profilecollectscript = []


def mutateScript(context, script, mutator):
Expand Down Expand Up @@ -119,6 +120,13 @@ def _executePlan(context, plan):
if exitCode != 0:
logging.warning("Profile script '%s' failed", plan.profilescript)

# Execute steps to manage the generated profile data, on the host.
_, _, exitCode, _ = _executeScript(
context, plan.profilecollectscript, "profilecollect"
)
if exitCode != 0:
logging.warning("Profile collect script '%s' failed", plan.profilecollectscript)

# Perform various metric extraction steps setup by testing modules.
for metric_collector in plan.metric_collectors:
try:
Expand Down Expand Up @@ -201,3 +209,4 @@ def __init__(self, test, litConfig, tmpDir, tmpBase):
self.tmpDir = tmpDir
self.tmpBase = tmpBase
self.read_result_file = default_read_result_file
self.profilefile = None