Skip to content

Commit 9b7db0f

Browse files
authored
Revise how we set tiering and pgo options for spmi benchmark collections (#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 #86410
1 parent 5b57d5c commit 9b7db0f

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

src/coreclr/scripts/superpmi_benchmarks.py

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -206,39 +206,52 @@ def build_and_run(coreclr_args, output_mch_name):
206206
"--framework", "net8.0", "--no-restore", "/p:NuGetPackageRoot=" + artifacts_packages_directory,
207207
"-o", artifacts_directory], _exit_on_fail=True)
208208

209+
# common BDN prefix
210+
collection_command = f"{dotnet_exe} {benchmarks_dll} --corerun {os.path.join(core_root, corerun_exe)} "
211+
212+
# test specific filters
209213
if benchmark_binary.lower().startswith("microbenchmarks"):
210-
# Disable ReadyToRun so we always JIT R2R methods and collect them
211-
collection_command = f"{dotnet_exe} {benchmarks_dll} --filter \"*\" --corerun {os.path.join(core_root, corerun_exe)} --partition-count {partition_count} " \
212-
f"--partition-index {partition_index} --envVars DOTNET_JitName:{shim_name} " \
213-
" DOTNET_ZapDisable:1 DOTNET_ReadyToRun:0 " \
214-
"--iterationCount 1 --warmupCount 0 --invocationCount 1 --unrollFactor 1 --strategy ColdStart --logBuildOutput"
214+
collection_command += f"--filter \"*\" --partition-count {partition_count} --partition-index {partition_index} "
215215
elif benchmark_binary.lower().startswith("demobenchmarks"):
216-
# Disable ReadyToRun so we always JIT R2R methods and collect them
217-
collection_command = f"{dotnet_exe} {benchmarks_dll} -f *CollisionBatcherTaskBenchmarks.* *GroupedCollisionTesterBenchmarks.* *GatherScatterBenchmarks.* " \
218-
" *OneBodyConstraintBenchmarks.* *TwoBodyConstraintBenchmarks.* *ThreeBodyConstraintBenchmarks.* *FourBodyConstraintBenchmarks.* " \
219-
" *SweepBenchmarks.* *ShapeRayBenchmarks.* *ShapePileBenchmark.* *RagdollTubeBenchmark.* " \
220-
f" --corerun {os.path.join(core_root, corerun_exe)} --envVars DOTNET_JitName:{shim_name} " \
221-
" DOTNET_ZapDisable:1 DOTNET_ReadyToRun:0 " \
222-
"--iterationCount 1 --warmupCount 0 --invocationCount 1 --unrollFactor 1 --strategy ColdStart --logBuildOutput"
216+
collection_command += "-f *CollisionBatcherTaskBenchmarks.* *GroupedCollisionTesterBenchmarks.* *GatherScatterBenchmarks.* " \
217+
" *OneBodyConstraintBenchmarks.* *TwoBodyConstraintBenchmarks.* *ThreeBodyConstraintBenchmarks.* *FourBodyConstraintBenchmarks.* " \
218+
" *SweepBenchmarks.* *ShapeRayBenchmarks.* *ShapePileBenchmark.* *RagdollTubeBenchmark.* "
219+
else:
220+
collection_command += "--filter \"*\" "
221+
222+
# common BDN arguments
223+
collection_command += "--iterationCount 1 --warmupCount 0 --invocationCount 1 --unrollFactor 1 --strategy ColdStart --logBuildOutput "
224+
225+
# common BDN environment var settings
226+
# Disable ReadyToRun so we always JIT R2R methods and collect them
227+
collection_command += f"--envVars DOTNET_JitName:{shim_name} DOTNET_ZapDisable:1 DOTNET_ReadyToRun:0 "
228+
229+
# custom BDN environment var settings
230+
if coreclr_args.tiered_pgo:
231+
collection_command += "DOTNET_TieredCompilation:1 DOTNET_TieredPGO:1"
232+
elif coreclr_args.tiered_compilation:
233+
collection_command += "DOTNET_TieredCompilation:1 DOTNET_TieredPGO:0"
223234
else:
224-
# Disable ReadyToRun so we always JIT R2R methods and collect them
225-
collection_command = f"{dotnet_exe} {benchmarks_dll} --filter \"*\" --corerun {os.path.join(core_root, corerun_exe)} --envVars DOTNET_JitName:{shim_name} " \
226-
" DOTNET_ZapDisable:1 DOTNET_ReadyToRun:0 " \
227-
"--iterationCount 1 --warmupCount 0 --invocationCount 1 --unrollFactor 1 --strategy ColdStart --logBuildOutput"
235+
collection_command += "DOTNET_TieredCompilation:0"
228236

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

233241
contents = []
234242
# Unset the JitName so dotnet process will not fail
243+
# Unset TieredCompilation and TieredPGO so the parent BDN process is just running with defaults
235244
if is_windows:
236245
contents.append("set JitName=%DOTNET_JitName%")
237246
contents.append("set DOTNET_JitName=")
247+
contents.append("set DOTNET_TieredCompilation=")
248+
contents.append("set DOTNET_TieredPGO=")
238249
else:
239250
contents.append("#!/bin/bash")
240251
contents.append("export JitName=$DOTNET_JitName")
241252
contents.append("unset DOTNET_JitName")
253+
contents.append("unset DOTNET_TieredCompilation")
254+
contents.append("unset DOTNET_TieredPGO")
242255
contents.append(f"pushd {performance_directory}")
243256
contents.append(collection_command)
244257

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

265-
if coreclr_args.tiered_compilation:
266-
script_args.append("--tiered_compilation");
267-
elif coreclr_args.tiered_pgo:
268-
script_args.append("--tiered_pgo");
269-
270-
script_args.append(script_name);
278+
script_args.append(script_name)
271279

272280
run_command(script_args, _exit_on_fail=True)
273281

0 commit comments

Comments
 (0)