-
Notifications
You must be signed in to change notification settings - Fork 752
RFC: Use AdvancedDLSupport instead of P/Invoke or GetFunctionPointerForDelegate #987
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
Comments
I am a bit concerned about
I don't know how much is this applicable to our users. We should discuss at the next call. Additionally, reading this I wonder if the calling convention is the reason for crash in #980 @Sngmng |
This is a pure .NET Core problem AFAIK (and the article is from 2018, it could be that this is fixed on .NET Core 3). Also ADL allows you to choose the style and fall back to delegates for unsupported cases. |
Well they mentioned if you dont want LGPL you can still ask them for a custom license:
This could be the issue, maybe. Should i try to use LoadLibrary and GetProcAdress instead? |
@Sngmng you can try fiddling with DllImportAttribute.CallingConvention |
I started prototyping Python C API interop layer: https://github.com/losttech/Python.Runtime.Native/tree/InterfaceBasedApiSets Run my own tests on Windows for
|
Hm, nevermind, longer reruns normalize it to 1.1-2.0x on all platforms.
For some reason BenchmarkDotNet did not pick up my local Mono installation. |
After some tweaking this is what I got (Calli through AdvancedDLSupport):
|
Thank you very much for running these :) What is the difference between CoreRt 3.0 and .NET Core 3.0 here? /edit: nvm, it's clear now :) |
This might solve the problem of Unity AOT compatibility issue |
@sekkit which issue are you referring to? BTW, I prototyped and benchmarked a simple PInvoke generator called
|
Finally, tested on Linux x64 (this one is in VM, so results might be inaccurate):
|
Actually, I think the way to go forward is pretty straightforward:
|
Sounds like a good plan, but I think if it's not too much work, we should have all of this directly in the main repository (at least after a bit of experimentation). I suggest we start a
That way we can do major changes to the architecture without dropping all of the current PRs. As long as we don't change |
I started this now, are you okay with me merging your work into the branch? |
#997 |
@sekkit would Unity AOT allow choosing Emit vs non-Emit implementation at runtime? The former is required for better performance. |
Reflectoin.Emit is not allowed. The above fork I posted: https://github.com/joonhwan/pythonnet is a AOT compatible implementation. No reflection overhead( fast-call branch) |
@sekkit it still relies on |
Well, we can still depend on it for Mono and .NET Core as both implement the |
Sure, go ahead. |
8000
Wait, on Windows too? |
Ah, sorry, I again fell for CoreRt vs CoreClr :/ Nevertheless, Mono and CoreRt support |
Since the unmanaged delegate changes are now merged, this one is obsolete. |
While investigating how to proceed on binding
libpython
I stumbled over this post: https://medium.com/@jarl.gullberg/an-introduction-to-adl-or-how-to-double-your-native-net-interop-performance-c008e4da54dbIt showcases https://github.com/Firwood-Software/AdvancedDLSupport and also benchmarks the individual options, which look quite devastating for the combination
GetFunctionPointerForDelegate
+Mono and at least "concerning" for the other frameworks.The library looks really slick and solves exactly our problem while (seemingly) delivering slightly better performance. It has however the catch of being LGPL. While this is perfectly fine for me, this means there might be a problem for applications trying to embed
Python.Runtime
ahead-of-time compiled or publishing to a closed app-store that prevents you from exchanging the LGPLed library locally.Comments?
The text was updated successfully, but these errors were encountered: