-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Use fast hashing helpers for types with trailing padding #118986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This is same as dotnet#111620 but with an extra thing: enable unconditional method body folding on `__GetFieldHelper` overrides (both the simplified ones that just return a negative number and normal ones).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves performance of value type hashing and equality comparisons by enabling fast hashing helpers for types with trailing padding. The changes allow value types to use memory-based comparisons up to a specified offset rather than requiring field-by-field comparisons when there's trailing padding.
Key changes:
- Modified the compiler to enable method body folding for
__GetFieldHelperoverrides unconditionally - Enhanced the fast path logic to handle value types with trailing padding by comparing memory up to the last field's end offset
- Updated the API semantics to use negative return values to indicate the byte offset for memory comparison
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| ObjectDataInterner.cs | Enables unconditional method body folding for ValueTypeGetFieldHelperMethodOverride methods |
| ValueTypeGetFieldHelperMethodOverride.cs | Adds fast path for value types that can use memory comparison up to a specific offset |
| ComparerIntrinsics.cs | Extends the analysis to support partial memory comparison up to the last field's end offset |
| ValueType.cs | Updates the runtime implementation to handle negative return values as byte offsets for memory comparison |
|
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas |
|
/azp run runtime-nativeaot-outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/ba-g the arm32 failures are known and have a fix out |
This is same as #111620 but with an extra thing: enable unconditional method body folding on
__GetFieldHelperoverrides (both the simplified ones that just return a negative number and normal ones).Before this PR we considered valuetypes as byte-hashable/comparable only if the valuetype didn't have any trailing padding.
This fixes things up so that we can consider types with trailing padding byte-hashable/comparable if the other requirements still hold (such as no double/float fields, no GC references, etc.) and there is a trailing padding. In this case, we remember the number of bytes that we should be looking at and ignore the rest.
Since this doesn't seem to provide meaningful size savings according to rt-sz, this is a throughput improvement, not a size improvement.
Before:
After:
Resolves #111542
Cc @dotnet/ilc-contrib