Hacker News new | ask | show | jobs
by jzwinck 911 days ago
Instead of literally loading the plugin into the same address space as the host process, you could launch it as a separate process and use sockets or shared memory to communicate. With a slight shift in API design this might actually be better than traditional dynamically loaded plugins. It will tend to level the performance playing field across languages (e.g. no JNI penalty for plugins written in a JVM language). And it will prevent plugins crashing the host.
1 comments

And the dispatch overhead will be a few orders of magnitude higher.
Passing a message via a shared memory queue (twice) is not 1000x slower than a non-inlineable function call.
You're right, but that's also not the entire workload. You have to also wake up the remote process in some way and, depending on the expected duration, probably wake up for the response. On pretty much all major platforms that work is measured in 10s of microseconds, which puts you easily into the 1000x slower than a non-inlineable function call category.
With the associated context switch it's bigger, if anything. Busy looping to wait if some memory changes isn't really viable for many scenarios.
That actually seems about the right order of magnitude.