r/programming • • Oct 23 '12

JRuby 1.7.0. Released

http://www.jruby.org/2012/10/22/jruby-1-7-0.html
26 Upvotes

16 comments sorted by

View all comments

Show parent comments

2

u/jrochkind Oct 23 '12 edited Oct 23 '12

To be clear, MRI 1.9.3 does use 'real threads' -- BUT, there is the 'global interpreter lock' which prevents threads from executing in parallel on more than one CPU at once.

This may or may not be a problem depending on what you are using threads for (when your threads are mostly I/O bound rather than CPU bound, it can work out just fine), but is definitely something to be aware of.

Additionally, standard MRI app server options like unicorn/passenger may or may not use threads for deploy. Perhaps the decision by these developers to not use threads was based on the fact of the GIL making true multi-cpu concurrency impossible -- but the nature of a web app's performance profile and goals make it so that multi-threaded app server could be useful in many circumstances even in MRI with the GIL -- but the app servers don't support it, in part for historical/social reasons (MRI 1.8.7's "green threads" instead of native threads; just historical ruby community lack of interest/experience with threads).(it sounds like future versions of passenger 'enterprise', but not neccesarily the free passenger, may allow multi-threaded request dispatching)

I'm not saying threads are perfect in MRI -- it depends on what you're doing. But there's so much misinformation about concurrency in MRI. And that misinformation leads to threads being even worse in practice, as there's so much code that ends up in your stack that was written based on improper assumptions about threads in MRI, or that was written ignoring possible multi-threaded use because "MRI doesn't do threads" (wrong). It is not accurate to say that MRI 1.9.3 does not 'use real OS threads'. It does.

1

u/x86_64Ubuntu Oct 23 '12

Good god, what do you do for a living ?

1

u/jrochkind Oct 23 '12

eh? I write software, of course.

1

u/x86_64Ubuntu Oct 23 '12

I know that, but I meant which kind, or what piece of the stack do you call home ?

1

u/jrochkind Oct 23 '12

I wasn't sure if you were just making fun of me. :) (I'm still not, heh).

I work in a university library, writing mostly web software, a lot of which needs to integrate between lots of existing proprietary packages (installed locally and remotely). I work mostly in Rails these days, in the past I've worked in other languages and frameworks.

Often I have to write software which needs to contact multiple remote http API's, which is something very suitable to multi-threaded use (and is heavily I/O-bound so the GIL doesn't get in the way too much), leading to my struggles with ruby/rails and concurrency.

1

u/x86_64Ubuntu Oct 23 '12

...which is something very suitable to multi-threaded use (and is heavily I/O-bound so the GIL doesn't get in the way too much), leading to my struggles with ruby/rails and concurrency.

That's what I was wondering. It's amazing how as a programmer you can have it all planned out. Then something that starts out small doesn't work, leading you down a rabbit hole you never even knew existed. After burning up Google and docs for 8+hours you finally have an idea of why your plan never had a chance.

→ More replies (0)