Skip to content

Commit

Permalink
SPMI: More information on CI failures (#77361)
Browse files Browse the repository at this point in the history
This enhances parts of the SPMI process with more information on failures.

Also fixes a bug I introduced when I added tpdiffs: when asmdiffs fails, it was not marking the entire pipeline as failing.
  • Loading branch information
jakobbotsch authored Oct 24, 2022
1 parent 090003a commit 9290f85
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
25 changes: 16 additions & 9 deletions src/coreclr/scripts/superpmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1691,10 +1691,7 @@ async def create_replay_artifacts(print_prefix, context_index, self, mch_file, e
"""
# Setup flags to call SuperPMI for both the diff jit and the base jit

flags = [
"-c", str(context_index),
"-v", "q" # only log from the jit.
]
flags = ["-c", str(context_index)]
flags += altjit_replay_flags

# Change the working directory to the core root we will call SuperPMI from.
Expand All @@ -1709,11 +1706,21 @@ async def create_one_artifact(jit_path: str, location: str, flags) -> str:
modified_env['DOTNET_JitStdOutFile'] = item_path
logging.debug("%sGenerating %s", print_prefix, item_path)
logging.debug("%sInvoking: %s", print_prefix, " ".join(command))
proc = await asyncio.create_subprocess_shell(" ".join(command), stderr=asyncio.subprocess.PIPE, env=modified_env)
await proc.communicate()
with open(item_path, 'r') as file_handle:
generated_txt = file_handle.read()
return generated_txt
proc = await asyncio.create_subprocess_shell(" ".join(command), stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE, env=modified_env)
(stdout, stderr) = await proc.communicate()

def create_exception():
return Exception("Failure while creating JitStdOutFile.\nExit code: {}\nstdout:\n{}\n\nstderr:\n{}".format(proc.returncode, stdout.decode(), stderr.decode()))

if proc.returncode != 0:
# No miss/replay failure is expected in contexts that were reported as having diffs since then they succeeded during the diffs run.
raise create_exception()

try:
with open(item_path, 'r') as file_handle:
return file_handle.read()
except BaseException as err:
raise create_exception() from err

# Generate diff and base JIT dumps
base_txt = await create_one_artifact(self.base_jit_path, base_location, flags + base_option_flags_for_diff_artifact)
Expand Down
11 changes: 10 additions & 1 deletion src/coreclr/scripts/superpmi_diffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ def main(main_args):
"-log_level", "debug",
"-log_file", log_file])

failed = False
if return_code != 0:
print("Failed during asmdiffs")
failed = True

print("Running superpmi.py tpdiff")

overall_md_tpdiff_summary_file = os.path.join(spmi_location, "tpdiff_summary.md")
Expand All @@ -240,6 +245,10 @@ def main(main_args):
"-log_level", "debug",
"-log_file", log_file])

if return_code != 0:
print("Failed during tpdiff")
failed = True

# If there are asm diffs, and jit-analyze ran, we'll get a diff_summary.md file in the spmi_location directory.
# We make sure the file doesn't exist before we run diffs, so we don't need to worry about superpmi.py creating
# a unique, numbered file. If there are no diffs, we still want to create this file and indicate there were no diffs.
Expand Down Expand Up @@ -269,7 +278,7 @@ def main(main_args):
# Finally prepare files to upload from helix.
copy_dasm_files(spmi_location, log_directory, "{}_{}".format(platform_name, arch_name))

if return_code != 0:
if failed:
print("Failure in {}".format(log_file))
return 1

Expand Down

0 comments on commit 9290f85

Please sign in to comment.