javapoet icon indicating copy to clipboard operation
javapoet copied to clipboard

Thread pool of pre-loaded VMs

Open nitely opened this issue 9 years ago • 7 comments
trafficstars

Would allow to run JS code in parallel. Should support asyncio. Should be transparent (ie: same API as for managing one VM)

nitely avatar Apr 18 '16 01:04 nitely

Doesn't V8 have it's own GIL? What would happen if you initialize multiple VMs inside a process?

thedrow avatar Jul 23 '16 05:07 thedrow

It's explained in the docs. You can run multiple VMs, each has its own GIL.

nitely avatar Jul 23 '16 11:07 nitely

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.

thedrow avatar Jul 24 '16 06:07 thedrow

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.

nitely avatar Jul 24 '16 11:07 nitely

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.

thedrow avatar Jul 24 '16 14:07 thedrow

I guess it must be a limitation of the gem (therubyracer?), maybe it's built on top of an older V8.

nitely avatar Jul 24 '16 14:07 nitely

Actually ExecJS disallows it and both therubyracer and miniracer don't support it. Kudos on having that already built in.

thedrow avatar Jul 24 '16 18:07 thedrow