Skip to content

Add method-list MIBC writer to dotnet-pgo - #134566

Merged
lewing merged 3 commits into
mainfrom
lewing-dotnet-pgo-method-list-mibc
Sep 24, 2026
Merged

lewing merged 3 commits into
mainfrom
lewing-dotnet-pgo-method-list-mibc

Conversation

@lewing

@lewing lewing commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Summary

  • add dotnet-pgo create-mibc-from-method-list for constructing deterministic profile root sets from JSON
  • resolve assembly-qualified declaring, parameter, and generic argument types through an Ecma-backed type-system context
  • reject invalid JSON, missing references, unresolved or ambiguous methods, wrong generic arity, duplicate entries, open generic types, and non-.mibc output
  • document the JSON format and add focused end-to-end tests, including MIBC dump round-tripping and input-order determinism

This is an exploratory, general-purpose profile-rooting tool motivated by the scenarios discussed in #132825. It does not claim to resolve that issue.

The tool supports controlled differential ReadyToRun investigations without collecting a trace or hand-authoring MIBC IL. It has already been used to:

  • root MemoryExtensions.Contains<int> through PublishReadyToRunPgoFiles, proving the profile was accepted and the compiled body was emitted while live execution still entered WasmR2RToInterpreterThunk; this isolated the problem to closed-generic dispatch/adapter behavior rather than missing rooting
  • root Delegate.CtorOpen and Delegate.CtorClosed, proving that adding the compiled bodies did not change delegate construction dispatch or timing and ruling out missing bodies as the cause of [wasm][coreclr][R2R] Delegate construction skips alternate-constructor lowering and remains interpreted #134564

This tool is not needed as a workaround for automatic hardware-intrinsic rooting in partial no-JIT compilations; #134030 fixed that behavior.

Validation

  • ./dotnet.sh test src/coreclr/tools/dotnet-pgo/tests/dotnet-pgo.Tests.csproj -c Debug — 7 passed
  • ./dotnet.sh test src/coreclr/tools/dotnet-pgo/tests/dotnet-pgo.Tests.csproj -c Release — 7 passed
  • repeated default compressed generation after a delay produced identical SHA-256 hashes
  • an assembly-qualified array signature continued to resolve successfully
  • a constructed generic type with an unqualified generic argument was rejected

Note

This pull request description was generated with GitHub Copilot.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/crossgen-contrib
See info in area-owners.md if you want to be subscribed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Comment thread src/coreclr/tools/dotnet-pgo/MethodListMibcWriter.cs

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.

Copilot review overview

🟡 Changes recommended

Critical emission failures can be reported as success, and array and generic type handling remains incomplete.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 High severity

Open (2)
What changed in this PR

Adds dotnet-pgo create-mibc-from-method-list for deterministic MIBC root generation from JSON.

Changes:

  • Adds Ecma-backed type and method resolution.
  • Adds deterministic MIBC emission and CLI integration.
  • Adds documentation, end-to-end tests, and build integration.
  • Review found unresolved critical validation and type-handling issues.
File Summary
src/​coreclr/​tools/​dotnet-pgo/​tests/​MethodListMibcTests.cs End-to-end method-list and round-trip tests.
src/​coreclr/​tools/​dotnet-pgo/​tests/​dotnet-pgo.Tests.csproj Defines the test project.
src/​coreclr/​tools/​dotnet-pgo/​README.md Documents the command and JSON format.
src/​coreclr/​tools/​dotnet-pgo/​Program.cs Dispatches the new command.
src/​coreclr/​tools/​dotnet-pgo/​PgoRootCommand.cs Registers command options and output handling.
src/​coreclr/​tools/​dotnet-pgo/​MibcEmitter.cs Provides deterministic compressed output.
src/​coreclr/​tools/​dotnet-pgo/​MethodListTypeSystemContext.cs Loads reference assemblies for resolution.
src/​coreclr/​tools/​dotnet-pgo/​MethodListMibcWriter.cs Resolves methods and emits MIBC roots; requires fixes for emission failures, array methods, and generic constraints.
src/​coreclr/​tools/​dotnet-pgo/​dotnet-pgo.csproj Excludes test sources from the tool.
src/​coreclr/​tools/​Common/​TypeSystem/​Common/​Utilities/​CustomAttributeTypeNameParser.cs Parses assembly-qualified type names; array, pointer, and byref qualification handling requires correction.
eng/​Subsets.props Registers the tests in the CLR tools subset.

Comment thread src/coreclr/tools/dotnet-pgo/MethodListMibcWriter.cs
Comment thread src/coreclr/tools/dotnet-pgo/PgoRootCommand.cs Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 24, 2026 16:27

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.

Copilot review overview

🔵 Needs a closer look

Address generic-constraint validation, synthetic declaring-type handling, culture-independent ordering, and the test pipe-read deadlock.

Review effort: Lite
Findings: None

Resolved since last review (2)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Validate generic constraints on instantiated methods

src/​coreclr/​tools/​dotnet-pgo/​MethodListMibcWriter.cs:174

MakeInstantiatedMethod only creates an instantiated descriptor; it does not validate generic constraints (the type system explicitly calls CheckConstraints() after instantiation in src/coreclr/tools/Common/TypeSystem/IL/UnsafeAccessors.cs:407-414). As written, a method list can pass an invalid class/struct/new()/interface argument and this command will accept and emit an invalid MIBC root. Reject candidates whose instantiated method fails CheckConstraints() and add a regression case for an invalid method generic argument.

This issue also appears on line 226 of the same file.

@lewing

lewing commented Sep 24, 2026

Copy link
Copy Markdown
Member Author

/ba-g ssl errors are tracked

@lewing
lewing merged commit 0b5e2d0 into main Sep 24, 2026
156 of 158 checks passed
@lewing
lewing deleted the lewing-dotnet-pgo-method-list-mibc branch September 24, 2026 20:45
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants