rubyjs / therubyracer

Embed the V8 Javascript Interpreter into Ruby
1.67k stars 190 forks source link

GIL lock in multithreaded environment #432

Closed BenTalagan closed 7 months ago

BenTalagan commented 7 years ago

It seems to me redundant with other issues, but not expressed like this specifically : when trying to run therubyracer in a thread, the whole MRI is locked until the thread times out or ends by itself.

2.3.1 :001> require "therubyracer"
2.3.1 :002> ctx = V8::Context.new timeout:10000; 
2.3.1 :003> Thread.new{ ctx.eval("while(true) {}"); puts "Done."} # => MRI is locked for 10 seconds

If I understand correctly, that issue should be solved by the 1.0 release right? (can't wait for it!)

mini_racer has that feature, but it hasn't that great bridge therubyracer has, so for the moment there is no 'ideal' solution for having a strong JS interpreter in a ruby env for the MRI.

cowboyd commented 7 years ago

It is true that a lot of deadlock issues will be solved with a 1.0 release. However, I have stalled out a bit because I no longer use therubyracer daily.

I'm currently looking for somebody to help push it over the finish line.

Skarlso commented 7 years ago

@cowboyd What does it take to get that over the finish line? Are there any potential Collaborators around?

cowboyd commented 7 years ago

There are probably about 20-40 hours of work left, and I am ready, happy and willing to pair with anybody willing to learn it. It is a fascinating project that is mind-warping in what it does, but it requires an investment of a lot of brainpower.

Whoever does carry the torch will come out the other side a changed developer with super-powers though.

Skarlso commented 7 years ago

@cowboyd Billy Mays here with another fantastic offer.... :-D never the less I'm very intrigued, but completely lacking time. I have a newborn on my hand and I have no idea how much time this would eat up. I'm guessing a lot? What do you recon? Maybe I can squeeze it in somewhere.

Skarlso commented 7 years ago

@cowboyd I might be able to do it with a buddy of mine who is very good at this stuff. :) I've been going over the PR, damn man, that's a LOT of stuff.

cowboyd commented 7 years ago

Yup, it's almost a complete re-write of the internals, so it's a lot lot of work. Like a lot lot. For those finding this later, here it is https://github.com/cowboyd/therubyracer/pull/348

It is a challenge for sure, but like all mountains worth climbing, the view from the summit is stunning.

True Story: therubyracer was conceived in my mind during the wee hours of wakefulness when I sat up with my first born back in 2009 and work began on it about 2 months later. Could it be fate?

Skarlso commented 7 years ago

That is quiet the awesome coincidence man. ☺️

Skarlso commented 7 years ago

Okay, let's say we are in. How do you want to do this? Where do we start?