javapoet
javapoet copied to clipboard
Thread pool of pre-loaded VMs
Would allow to run JS code in parallel. Should support asyncio. Should be transparent (ie: same API as for managing one VM)
Doesn't V8 have it's own GIL? What would happen if you initialize multiple VMs inside a process?
It's explained in the docs. You can run multiple VMs, each has its own GIL.
Oh that's really cool. I didn't know that it was possible. If you try to do the same with Python you're going to encounter some nasty issues.
Yes, the alternative (in Python) is to spawn a child process. V8's devs could have done the same to work around the GIL, but instead they added the concept of isolate (a VM for all practical purposes) to achieve the same with threads (I dunno why they wanted threads so badly, since with isolates you still share nothing). I think that feature is there to support web workers.
I thought that it's not possible since in MRI Ruby you are not allowed to use more than one V8 VM in one process.
I guess it must be a limitation of the gem (therubyracer?), maybe it's built on top of an older V8.
Actually ExecJS disallows it and both therubyracer and miniracer don't support it. Kudos on having that already built in.