Skip to content

Configure r2r to disable runtime code generation in the r2r_interpreter configuration - #5295

Open
BrzVlad wants to merge 1 commit into
dotnet:mainfrom
BrzVlad:fix-r2r-interp
Open

Configure r2r to disable runtime code generation in the r2r_interpreter configuration#5295
BrzVlad wants to merge 1 commit into
dotnet:mainfrom
BrzVlad:fix-r2r-interp

Conversation

@BrzVlad

@BrzVlad BrzVlad commented Sep 1, 2026

Copy link
Copy Markdown
Member

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-arguments, which will be forwarded to bdn via the job arguments (job.WithMsBuildArguments).

…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).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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 msBuildArguments input to RecommendedConfig.Create and apply it to the BDN Job via WithMsBuildArguments.
  • Extend src/benchmarks/micro argument parsing to accept a new --msbuild-arguments flag and forward the values into RecommendedConfig.Create.
  • Update scripts/run_performance_job.py to supply the required MSBuild property when runtime_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.

Comment thread src/benchmarks/micro/Program.cs
Comment on lines 33 to 36
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);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

@BrzVlad

BrzVlad commented Sep 1, 2026

Copy link
Copy Markdown
Member Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants