Repository navigation
[NativeAOT] Hash generic arguments in NativeFormat metadata - #136886
Merged
Merged
Conversation
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: 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. |
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
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
agocke
marked this pull request as ready for review
November 3, 2026 00:37
agocke
enabled auto-merge (squash)
November 3, 2026 00:38
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
disabled auto-merge
November 3, 2026 17:51
agocke
enabled auto-merge (squash)
November 3, 2026 17:51
Contributor
There was a problem hiding this comment.
🟢 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
MethodInstantiationandTypeInstantiationSignatureschemas. - 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
MichalStrehovsky
approved these changes
Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Include generic arguments when hashing NativeFormat
MethodInstantiationandTypeInstantiationSignaturerecords.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.