Skip to content

Commit

Permalink
Revise how we set tiering and pgo options for spmi benchmark collecti…
Browse files Browse the repository at this point in the history
…ons (dotnet#87292)

Don't set these in the BDN environment; set them via the BDN command line
so they only impact the process being benchmarked.

Fixes dotnet#86410
  • Loading branch information
AndyAyersMS committed Jun 9, 2023
1 parent 5b57d5c commit 9b7db0f
Showing 1 changed file with 30 additions and 22 deletions.
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:
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

0 comments on commit 9b7db0f

Please sign in to comment.