Closed KeKl closed 6 years ago
I tested PInvoke vs delegate vs calli for vkCreateInstance
. With RyuJIT (tested for x64), their perf was on par. I assume the jitter optimizes the delegate approach. With the old jitter (tested for x86), delegate was noticeably slower. Didn't delve any deeper than that, though.
Ok, i tested this some years ago. Didn´t know that the new jitter do this better.
Hey, thanks for the feedback! I'm going to reopen this issue as the SuppressUnmanagedCodeSecurity
attribute does need adding.
As 0.4.0 has moved away from using PInvoke except during function initialisation, this optimisation attribute is no longer required. I'll check if there's anything comparable required for delegate calls, but the performance recommendations above should be addressed.
I have some performance improvments:
The function
GetDelegateForFunctionPointer
is really slow compared to a PInvoke or a Calli instruction injection into the IL .dll.In OpenTK there is an il rewriter (example above). It injects the calli instruction into the IL. A similiar Approach was done in SharpDx. There is also a proposal https://github.com/dotnet/roslyn/issues/11475
SuppressUnmanagedCodeSecurity
Attribute for pinvokeUse the
SuppressUnmanagedCodeSecurity
Attribute for Releases increases the performance and should be not a problem in the use case.