-
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
mono AOT compiler cannot resolve and inline static virtual calls in gshared methods #75801
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
cc @BrzVlad |
@vargaz As you know I am working on the 7.0 fix and I wonder whether I could avoid copying the old code back. I have two questions:
- private interface INegator<T> where T : struct
+ private interface INegator<T> where T : struct, INumber<T>
- equals = TNegator.NegateIfNeeded(Vector256.Equals(values, Vector256.LoadUnsafe(ref currentSearchSpace)));
+ equals = Vector256.Equals(values, Vector256.LoadUnsafe(ref currentSearchSpace));
+ if (typeof(TNegator) == typeof(Negate)) // assuming I would remove T from INegator
+ {
+ equals = ~equals;
+ }
|
I think the lowest risk for net 7.0 is to copy the code back and put it inside ifdefs. |
@vargaz I assume that it means that the two workarounds posted above would not help? I have started copying the code and it's a lot of code (hundreds of lines) so it's not minimal risk. |
You can add copy of the old implementation files verbatim under a different name, and just do minimal changes on top of it to get things compile. |
Mostly fixes dotnet#75801. Some restrictions still remain, mostly methods with generic arguments like INegator`1<T>:NegateIfNeeded<Vector128<T>>.
…containing static virtual calls. These calls cannot be resolved at compile time in gshared methods, so they cannot be inlined etc. They are used in perf sensitive BCL code like SpanHelpers. To fix this, modify the AOT compiler so in addition to the gshared versions, it emits specific instances of these methods if possible. This only affects a small subset of gshared methods so it doesn't lead to a noticable code size increase. Fixes dotnet#75801.
…containing static virtual calls. (#76033) These calls cannot be resolved at compile time in gshared methods, so they cannot be inlined etc. They are used in perf sensitive BCL code like SpanHelpers. To fix this, modify the AOT compiler so in addition to the gshared versions, it emits specific instances of these methods if possible. This only affects a small subset of gshared methods so it doesn't lead to a noticable code size increase. Fixes #75801.
This only solves (part of) the AOT slowdowns, the interpreter slowdowns are still there. |
So for a simple test case:
So there is still about a 5% slowdown, but it's not that bad anymore. |
Testcase:
When calling
IndexOfValueType<byte, DontNegate<byte>>
, the AOT compiler will compile a shared instance for bytes/enums with byte basetype, but inside the shared method it can't resolve thecall to DontNegate so it doesn't get inlined.
This is hit with the recent BCL changes to SpanHelpers.
The text was updated successfully, but these errors were encountered: