-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Expose a new CallConvSuppressGCTransition so SuppressGCTransition works for function pointers #38134
Comments
CC. @333fred, @davidwrighton, @AaronRobinsonMSFT, @jkotas I've marked this |
namespace System.Runtime.CompilerServices
{
public class CallConvSuppressGCTransition
{
}
} |
I think I have a scenario for this within CoreLib. Is there an experimental branch where this is implemented where I can run some tests? |
@GrabYourPitchforks Nope. I don't think we will be creating an experimental branch for this work. What scenario are you thinking of? |
@AaronRobinsonMSFT I have a branch where I'm experimenting resolving #13091, which is the The line I highlighted above is a calli into an unmanaged p/invoke: either Edit: Using the managed calli hack in the sample above was just a proof of concept. If I leave the function pointer as |
@GrabYourPitchforks Can I assume the trickery with the |
@AaronRobinsonMSFT Yeah, that trickery was just to demonstrate that suppressing the GC transition saves a few nanoseconds. Since this is a hot path I'll take whatever win I can get. The only difference in the runs below is whether the delegate is typed as | Method | Job | Toolchain | Mean | Error | StdDev | Ratio |
|---------- |----------- |---------------- |---------:|---------:|---------:|------:|
| GetUtcNow | Job-CCKDPC | suppressgctrans | 27.14 ns | 0.082 ns | 0.073 ns | 0.94 |
| GetUtcNow | Job-OKNQNN | withgctrans | 28.81 ns | 0.249 ns | 0.233 ns | 1.00 | |
< 2 ns is a bit hard for me to justify anything actually. However, since there is a measurable difference and I don't think this work will be too hard I will mark this as .NET 6. |
Yeah, 2ns isn't going to make or break this. It's more to point out that if this capability existed, we'd take advantage of it. Related question: the Win32 API might - under some rare edge cases - call a |
As an interesting note, there are some cases where the
|
pause instruction is fine with |
Not to my understanding. The
Even that doesn't really move me much in these kind of APIs. What I am far more sensitive to is the reduced error and standard deviation. I think the high order bit should be predictable execution followed immediately by performance. Obviously there are nuances here but in general a steady and predictable platform is what I want. |
The following is where one would start in the runtime to add support for this: runtime/src/coreclr/src/vm/siginfo.hpp Lines 782 to 797 in 45f8a37
The various uses would need to pass the |
Just to clarify - this issue isn't blocking me. We're able to find significant perf wins, even without this feature. |
@GrabYourPitchforks Appreciate the clarification. I like to have some breadcrumbs in issues in case someone else does the work or I pick this up 4 months from now. Since it was in my head I took 15 minutes to verify my understanding and add notes for future me or some industrious soul. |
Expose a new
CallConvSuppressGCTransition
type so function pointers can also opt into theSuppressGCTransitionAttribute
behavior.Proposed API
The text was updated successfully, but these errors were encountered: