镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

[NativeAOT] Hash generic arguments in NativeFormat metadata - #136886

Merged
agocke merged 3 commits into
dotnet:mainfrom
agocke:nativeformat-generic-argument-hashing
Nov 3, 2026
Merged

agocke merged 3 commits into
dotnet:mainfrom
agocke:nativeformat-generic-argument-hashing

Conversation

@agocke

@agocke agocke commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Summary

Include generic arguments when hashing NativeFormat MethodInstantiation and TypeInstantiationSignature records.

Equality already compares GenericTypeArguments, but hashing omits them. Instantiations of the same generic type or method therefore collide regardless of their arguments, causing long chains in the metadata writer's structural record pool.

Performance

Azure MCP measurement: a ILC comparison measured 331.014 s before versus 291.057 s after (12.1% lower wall time), with byte-identical object files. The measured boundary was managed ILC entry through object output, excluding native linking and SDK publish.

Include generic arguments in the hashes of type and method instantiation records, matching their structural equality comparisons. Regenerate the writer with the current System.HashCode implementation and add focused equality, collision, nesting, and recursive-definition regression cases.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d7781a32-4bd5-4bc1-98e8-78ef1eb83cac
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 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: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.

Keep one theory covering type and method instantiations and check only that generic argument changes affect hashing. Drop redundant equality, nesting, and recursive-definition cases and the all-distinct-hashes requirement.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d7781a32-4bd5-4bc1-98e8-78ef1eb83cac
Keep this change limited to the NativeFormat schema flags and regenerated writer. Restore the signature tests and test project references to their original contents.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d7781a32-4bd5-4bc1-98e8-78ef1eb83cac
@agocke
agocke requested a balanced review from Copilot November 3, 2026 17:51
@agocke
agocke disabled auto-merge November 3, 2026 17:51
@agocke
agocke enabled auto-merge (squash) November 3, 2026 17:51

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.

🟢 Approval recommended

No active review issues remain for the update to include generic arguments in NativeFormat metadata hashing.

No open issues 🎉

What changed in this PR

This PR updates NativeAOT’s NativeFormat metadata hashing to include generic arguments, reducing collisions in the metadata writer’s structural record pool.

Changes:

  • Marks generic argument lists for hash enumeration in the MethodInstantiation and TypeInstantiationSignature schemas.
  • Updates the generated writer to hash each generic argument alongside the method or generic type.
File Description
src/​coreclr/​tools/​Common/​Internal/​Metadata/​NativeFormat/​Generator/​SchemaDef.cs Enables generic argument hashing for both record types.
src/​coreclr/​tools/​aot/​ILCompiler.MetadataTransform/​Internal/​Metadata/​NativeFormat/​Writer/​NativeFormatWriterGen.cs Includes generic arguments in both generated GetHashCode implementations.

Review effort: Balanced

@agocke
agocke merged commit 1ef71ad into dotnet:main Nov 3, 2026
100 of 102 checks passed
@agocke
agocke deleted the nativeformat-generic-argument-hashing branch November 3, 2026 22:29
@github-project-automation github-project-automation Bot moved this to Done in AppModel Nov 3, 2026
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants