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

Revise how we set tiering and pgo options for spmi benchmark collections #87292

Merged
merged 2 commits into from
Jun 9, 2023
Merged
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
52 changes: 30 additions & 22 deletions src/coreclr/scripts/superpmi_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,39 +206,52 @@ def build_and_run(coreclr_args, output_mch_name):
"--framework", "net8.0", "--no-restore", "/p:NuGetPackageRoot=" + artifacts_packages_directory,
"-o", artifacts_directory], _exit_on_fail=True)

# common BDN prefix
collection_command = f"{dotnet_exe} {benchmarks_dll} --corerun {os.path.join(core_root, corerun_exe)} "

# test specific filters
if benchmark_binary.lower().startswith("microbenchmarks"):
# Disable ReadyToRun so we always JIT R2R methods and collect them
collection_command = f"{dotnet_exe} {benchmarks_dll} --filter \"*\" --corerun {os.path.join(core_root, corerun_exe)} --partition-count {partition_count} " \
f"--partition-index {partition_index} --envVars DOTNET_JitName:{shim_name} " \
" DOTNET_ZapDisable:1 DOTNET_ReadyToRun:0 " \
"--iterationCount 1 --warmupCount 0 --invocationCount 1 --unrollFactor 1 --strategy ColdStart --logBuildOutput"
collection_command += f"--filter \"*\" --partition-count {partition_count} --partition-index {partition_index} "
elif benchmark_binary.lower().startswith("demobenchmarks"):
# Disable ReadyToRun so we always JIT R2R methods and collect them
collection_command = f"{dotnet_exe} {benchmarks_dll} -f *CollisionBatcherTaskBenchmarks.* *GroupedCollisionTesterBenchmarks.* *GatherScatterBenchmarks.* " \
" *OneBodyConstraintBenchmarks.* *TwoBodyConstraintBenchmarks.* *ThreeBodyConstraintBenchmarks.* *FourBodyConstraintBenchmarks.* " \
" *SweepBenchmarks.* *ShapeRayBenchmarks.* *ShapePileBenchmark.* *RagdollTubeBenchmark.* " \
f" --corerun {os.path.join(core_root, corerun_exe)} --envVars DOTNET_JitName:{shim_name} " \
" DOTNET_ZapDisable:1 DOTNET_ReadyToRun:0 " \
"--iterationCount 1 --warmupCount 0 --invocationCount 1 --unrollFactor 1 --strategy ColdStart --logBuildOutput"
collection_command += "-f *CollisionBatcherTaskBenchmarks.* *GroupedCollisionTesterBenchmarks.* *GatherScatterBenchmarks.* " \
" *OneBodyConstraintBenchmarks.* *TwoBodyConstraintBenchmarks.* *ThreeBodyConstraintBenchmarks.* *FourBodyConstraintBenchmarks.* " \
" *SweepBenchmarks.* *ShapeRayBenchmarks.* *ShapePileBenchmark.* *RagdollTubeBenchmark.* "
else:
collection_command += "--filter \"*\" "

# common BDN arguments
collection_command += "--iterationCount 1 --warmupCount 0 --invocationCount 1 --unrollFactor 1 --strategy ColdStart --logBuildOutput "

# common BDN environment var settings
# Disable ReadyToRun so we always JIT R2R methods and collect them
collection_command += f"--envVars DOTNET_JitName:{shim_name} DOTNET_ZapDisable:1 DOTNET_ReadyToRun:0 "

# custom BDN environment var settings
if coreclr_args.tiered_pgo:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mind also pulling the --iterationCount 1 --warmupCount 0 --invocationCount 1 --unrollFactor 1 --strategy ColdStart in common case?

Also, shouldn't you be passing iterationCount, etc. if for tiered/pgo runs? And a note about DOTNET_ZapDisable:1 DOTNET_ReadyToRun:0 too. Do we still want them for tiered/pgo runs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no common case right now, are you saying I should factor the common aspects out (or at least the common trailing elements)?

I wasn't planning on changing how we collect at this point. I would have to study the impact of altering BDN strategy to see if it adds value.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no common case right now, are you saying I should factor the common aspects out (or at least the common trailing elements)?

Yes, that's what I meant.

I wasn't planning on changing how we collect at this point. I would have to study the impact of altering BDN strategy to see if it adds value.

Sure, we can limit this PR for just the changes you have currently and rethink about longer term strategy of how we should collect them in a later PR.

collection_command += "DOTNET_TieredCompilation:1 DOTNET_TieredPGO:1"
elif coreclr_args.tiered_compilation:
collection_command += "DOTNET_TieredCompilation:1 DOTNET_TieredPGO:0"
else:
# Disable ReadyToRun so we always JIT R2R methods and collect them
collection_command = f"{dotnet_exe} {benchmarks_dll} --filter \"*\" --corerun {os.path.join(core_root, corerun_exe)} --envVars DOTNET_JitName:{shim_name} " \
" DOTNET_ZapDisable:1 DOTNET_ReadyToRun:0 " \
"--iterationCount 1 --warmupCount 0 --invocationCount 1 --unrollFactor 1 --strategy ColdStart --logBuildOutput"
collection_command += "DOTNET_TieredCompilation:0"

# Generate the execution script in Temp location
with TempDir() as temp_location:
script_name = os.path.join(temp_location, script_name)

contents = []
# Unset the JitName so dotnet process will not fail
# Unset TieredCompilation and TieredPGO so the parent BDN process is just running with defaults
if is_windows:
contents.append("set JitName=%DOTNET_JitName%")
contents.append("set DOTNET_JitName=")
contents.append("set DOTNET_TieredCompilation=")
contents.append("set DOTNET_TieredPGO=")
else:
contents.append("#!/bin/bash")
contents.append("export JitName=$DOTNET_JitName")
contents.append("unset DOTNET_JitName")
contents.append("unset DOTNET_TieredCompilation")
contents.append("unset DOTNET_TieredPGO")
contents.append(f"pushd {performance_directory}")
contents.append(collection_command)

Expand All @@ -262,12 +275,7 @@ def build_and_run(coreclr_args, output_mch_name):
"-output_mch_path", output_mch_name,
"-log_level", "debug"]

if coreclr_args.tiered_compilation:
script_args.append("--tiered_compilation");
elif coreclr_args.tiered_pgo:
script_args.append("--tiered_pgo");

script_args.append(script_name);
script_args.append(script_name)

run_command(script_args, _exit_on_fail=True)

Expand Down