Configure r2r to disable runtime code generation in the r2r_interpreter configuration - #5295
Configure r2r to disable runtime code generation in the r2r_interpreter configuration#5295BrzVlad wants to merge 1 commit into
Conversation
…er configuration This configuration used to be hardcoded in crossgen2, but it workaround was recently reverted with proper support added in dotnet/runtime@5b11923. This means r2r_interpreter configuration needs to pass `--target-allows-runtime-code-generation:false` to crossgen. This can be achieved by having the bdn autogenerated project receive the msbuild property `PublishReadyToRunCrossgen2ExtraArgs` initialized to this extra arg. Given bdn doesn't support this configuration via its cli arguments (https://github.com/dotnet/BenchmarkDotNet/blob/master/src/BenchmarkDotNet/ConsoleArguments/CommandLineOptions.cs), we add a new argument to the microbenchmark project --msbuild-argument, which will be forwarded to bdn via the job arguments (job.WithMsBuildArguments).
There was a problem hiding this comment.
🟡 Changes recommended
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates the performance microbenchmark harness so the coreclr_r2r_interpreter configuration can disable runtime code generation by passing an extra MSBuild property through BenchmarkDotNet to Crossgen2 (PublishReadyToRunCrossgen2ExtraArgs=--target-allows-runtime-code-generation:false).
Changes:
- Add an optional
msBuildArgumentsinput toRecommendedConfig.Createand apply it to the BDNJobviaWithMsBuildArguments. - Extend
src/benchmarks/microargument parsing to accept a new--msbuild-argumentsflag and forward the values intoRecommendedConfig.Create. - Update
scripts/run_performance_job.pyto supply the required MSBuild property whenruntime_type == coreclr_r2r_interpreter.
File summaries
| File | Description |
|---|---|
| src/harness/BenchmarkDotNet.Extensions/RecommendedConfig.cs | Accepts optional MSBuild arguments and applies them to the BenchmarkDotNet job configuration. |
| src/benchmarks/micro/Program.cs | Adds parsing/forwarding of a new CLI flag to inject MSBuild arguments into the benchmark job. |
| scripts/run_performance_job.py | Supplies the R2R interpreter Crossgen2 extra arg via the new MSBuild-arguments pathway. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| argsList = CommandLineOptions.ParseAndRemoveStringsParameter(argsList, "--exclusion-filter", out exclusionFilterValue); | ||
| argsList = CommandLineOptions.ParseAndRemoveStringsParameter(argsList, "--category-exclusion-filter", out categoryExclusionFilterValue); | ||
| argsList = CommandLineOptions.ParseAndRemoveStringsParameter(argsList, "--msbuild-arguments", out msBuildArguments); | ||
| CommandLineOptions.ParseAndRemoveBooleanParameter(argsList, "--disasm-diff", out getDiffableDisasm); |
There was a problem hiding this comment.
Tested with ./scripts/benchmarks_ci.py ... "--bdn-arguments=--msbuild-arguments /p:PublishReadyToRunCrossgen2ExtraArgs=--target-allows-runtime-code-generation:false". Not sure if further hardening is relevant.
|
@DrewScoggins Note that passing this crossgen2 argument to an older version that doesn't support it will simply crash the r2r execution. Not sure how this versioning is handled, whether we are guaranteed that dotnet/performance main is used only with latest main from dotnet/runtime and not with older versions. |
This configuration used to be hardcoded in crossgen2, but it workaround was recently reverted with proper support added in dotnet/runtime@5b11923. This means r2r_interpreter configuration needs to pass
--target-allows-runtime-code-generation:falseto crossgen. This can be achieved by having the bdn autogenerated project receive the msbuild propertyPublishReadyToRunCrossgen2ExtraArgsinitialized to this extra arg.Given bdn doesn't support this configuration via its cli arguments (https://github.com/dotnet/BenchmarkDotNet/blob/master/src/BenchmarkDotNet/ConsoleArguments/CommandLineOptions.cs), we add a new argument to the microbenchmark project
--msbuild-arguments, which will be forwarded to bdn via the job arguments (job.WithMsBuildArguments).