3 ms·
I wonder what the overhead of FFI will look like now that Green Threads are a thing :^)
by neonsunset 3y ago
I wonder what the overhead of FFI will look like now that Green Threads are a thing :^)
- metaltyphoon 3y agoI’m going to say not good, based on GO’s performance and the latest .NET finding on experimental green threads.
- sebazzz 3y agoHow does that work exactly, because at some point the JVM must call the native socket/file/etc API’s right? That isn’t any difference than in .NET, is it?
- neonsunset 3y ago.NET does not need to deal with side effects of threadlocals, do thread pinning or much else - it calls into native code directly like Rust or C++ to its dynamically linked dependencies. The only cost is pinning objects, if you are passing let's say a pointer to a managed array or string (upfront cost is free but you pay for it later on if you pin for a long time), and notifying GC not to preempt the thread while it's in unmanaged land. You can get an estimate of FFI overhead difference here: https://web.archive.org/web/20230715041452/https://vancan1ty.com/blog/post/52 https://web.archive.org/web/20230715041452/https://vancan1ty...
- kaba0 3y agoI believe Loom virtual threads will become pinned if they call native functions, so besides taking away place from more virtual threads, they won’t have to have much overhead.