-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[release/7.0-rc2] [Mono] Restore old code to solve the recent SpanHelpers regressions #75996
[release/7.0-rc2] [Mono] Restore old code to solve the recent SpanHelpers regressions #75996
Conversation
Tagging subscribers to this area: @dotnet/area-system-memory Issue DetailsBackport of #75917 to release/7.0-rc2 Customer ImpactTestingRiskIMPORTANT: Is this backport for a servicing release? If so and this change touches code that ships in a NuGet package, please make certain that you have added any necessary package authoring and gotten it explicitly reviewed.
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
internal static int LastIndexOfAnyValueType<T>(ref T searchSpace, T value0, T value1, T value2, T value3, int length) where T : struct, INumber<T> | ||
=> LastIndexOfAnyValueType<T, DontNegate<T>>(ref searchSpace, value0, value1, value2, value3, length); | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
internal static int LastIndexOfAnyExceptValueType<T>(ref T searchSpace, T value0, T value1, T value2, T value3, int length) where T : struct, INumber<T> | ||
=> LastIndexOfAnyValueType<T, Negate<T>>(ref searchSpace, value0, value1, value2, value3, length); | ||
#endif | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveOptimization)] | ||
private static int LastIndexOfAnyValueType<TValue, TNegator>(ref TValue searchSpace, TValue value0, TValue value1, TValue value2, TValue value3, int length) |
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.
Did we validate that code like this which should be unreferenced in the mono build is correctly being trimmed away?
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.
I just pulled down and built the change, and it looks like almost everything is. The INegator<T>
interface isn't being removed, but that's small potatoes.
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.
Thanks, @stephentoub. I'd be happy to follow this up with another PR for GA to ifdef that orphaned code away, but I wasn't able to explore that today.
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.
The INegator interface isn't being removed.
What is that? IL linker bug?
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.
@stephentoub / @jkotas - Should we expect action from this comment in this PR?
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.
Should we expect action from this comment in this PR?
No
What is that? IL linker bug?
I believe so, but I've not investigated further yet.
This was approved by Tactics via chat. |
Adam wrote this on the previous PR: #75932 (comment)
@radekdoulik @radical can you confirm the perf looks good, and if it does, can you please sign off? |
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.
Lets take this now
* Fix querying L3 cache size on osx-x64 (#75870) Co-authored-by: Filip Navara <[email protected]> * KeyChar should be preserved for Ctrl+Letter (#75861) Co-authored-by: Adam Sitnik <[email protected]> * Try re-enabling System.Transactions.Local tests on Arm64 (#75703) Co-authored-by: Jan Kotas <[email protected]> * Updating inbox source generators to Roslyn 4.4 and removing polyfill approach (#75717) (#75875) * Removed internalProperties group from proxy and tests. (#75906) Co-authored-by: Ilona Tomkowicz <[email protected]> * [release/7.0-rc2] Fixing SpanHelpers.LastIndexOfAnyValueType to no longer create out of bounds GC refs (#75885) * Fixing SpanHelpers.LastIndexOfAnyValueType to no longer create out of bounds GC refs * Apply suggestions from code review Co-authored-by: Adam Sitnik <[email protected]> * Adjusting the comment as per PR review feedback Co-authored-by: Tanner Gooding <[email protected]> Co-authored-by: Adam Sitnik <[email protected]> * Bump intellisense package for RC2 to include latest comments for Numerics (#75938) Co-authored-by: carlossanlop <[email protected]> * [release/7.0-rc2] [Mono] Restore old code to solve the recent SpanHelpers regressions (#75996) * bring back the old code... * bring back more old code * Use an ifdef around clr code instead of a separate file * Delete SpanHelpers.Clr.cs * Remove a remaining INumber<T> helper from mono Co-authored-by: Adam Sitnik <[email protected]> Co-authored-by: Jeff Handley <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Filip Navara <[email protected]> Co-authored-by: Adam Sitnik <[email protected]> Co-authored-by: Jan Kotas <[email protected]> Co-authored-by: Jose Perez Rodriguez <[email protected]> Co-authored-by: Ilona Tomkowicz <[email protected]> Co-authored-by: Tanner Gooding <[email protected]> Co-authored-by: Carlos Sanchez <[email protected]> Co-authored-by: carlossanlop <[email protected]> Co-authored-by: Jeff Handley <[email protected]>
I've seen frequent crashes with rc1 on Applying the patch from this PR seems to fix those crashes for me, so it's apparently not just a performance fix. |
Thanks for the pointer, but this turned out to be unrelated. (#75857 also only affects the vector code, and we don't currently support vectors in Mono on s390x, so this code would never trigger either way.) The actual root cause was a codegen bug in Mono, where the |
Backport of #75917 to release/7.0-rc2. This replaces backport PR #75932.
/cc @jeffhandley @adamsitnik @radical
Customer Impact
Fixes large performance regression #75709 in library code when running on mono (AOT, interpreter) introduced in rc1 (#74086)
Testing
Benchmarks were manually run before merge into main to ensure we were seeing expected recovery. We also have the automated benchmarks running now, and we will update with the results once available.
Risk
We explored several approaches to this fix along the way. We concluded that restoring the old implementation of these methods for use on mono only was the best bet, but those had to be adapted to align with other refactoring that had been done. The result is introducing a SpanHelpers.Mono.cs file with implementations that don't use
INumber<T>
and carry the previous intrinsics-based implementations.This approach keeps the CoreCLR performance improvements intact while avoiding the mono regression.