Matz mentioned off hand at the last Ruby Conf that Nobu has been experimenting without the GIL. It's scary because running code without the GIL will expose a lot of existing concurrency bugs that have been safely hidden thus far. A lot of code works fine with the GIL, since it prevents the full parallelism that would exercise all possible race conditions, so it's unlikely they'd remove it in anything other than a major release, i.e. Ruby 3.0
An other issue, the one CPython has hit repeatedly when trying to remove the GIL — and the big sticking point for the core team in general — is that single-threaded performances of a naive interpreter suffer a lot when splitting the GIL: instead of a single lock which is taken and released relatively rarely, the interpreter has to juggle with many small locks which it has to acquire and release much more often. When David Beazley looked back on the GIL-less patch for CPython 1.4[0] he measured performance hits of 4x~7x.
Though in the case of CPython most of the cost comes from the refcounting. MRI is not refcounted so the performance hit of finer locking would probably be lower.
This is where JRuby / Truffle is exciting - JRuby's been exciting for a long time and never quite reached it's potential, but with these latest projects it could become the main ruby implementation - and these complex issues are already largely solved in the JVM.
I really doubt jruby will ever become the main ruby implementation, as awesome as it is. The fact is that too much of the ruby ecosystem is built on calling out to C, and jruby officially abandoned cext shimming a while back. And while ffi is good, it's often not nearly as flexible.
There's also the fact that because of slow startup times, the modify/test cycle can be quite frustrating compared to working with MRI.
The truth is that the vast majority of ruby applications never reach a point where the steady-state post-warmup performance of jruby with pure ruby outweighs the fast-startup moderate performance of mri+cexts. And ones that do reach that point often have a better case for moving to something else anyways (including other jvm technologies that can now be shimmed on via jruby and eventually replace the whole thing).
Truffle can reach faster performance in pure-ruby than MRI+cext. Agreed though, it'll be a uphill battle to change the interpreter of choice, and JRuby will have to have much faster startup to get it to work
That's awesome - so it'll have a JVM of sorts bundled within it but that's totally hidden, it runs just like MRI? How does memory usage compare - running JRuby on a 512mb dyno would be sweet.
What you + the jruby team is doing is truly awesome, at some point I'll have to try my hand at contributing to it :)
Yeah, but it's not just bundled - to me that it sounds like we just link against a JVM library to produce a binary. What we do is to compile the Ruby interpreter, the JIT compiler and the JVM runtime in one big step - whole program analysis.
Creating MRI/CPython/Perl5-style VM without GIL is not much harder than creating the same thing with GIL. But the problem is that converting existing implementation to not use GIL is comparable amount of work.
It mentions Rubinius briefly (it doesn't have a GIL).
Slightly of topic, but can anyone with better knowledge then myself of ruby implementations and internals explain why it hasn't caught much of a following (what it seems anyway, I may be wrong here).
To me it seems like a pretty good idea to implement Ruby mostly in Ruby, since it makes it easier to get contributions (especially to less performance-sensitive parts of the language, e.g. parts of the standard lib).
Rubinius is neat, but for me personally (and I think most of the community) it's performance. Writing C enables optimizations by hand that still yield very significant performance gains over the best of what any other high level language (java, c++, ruby) can muster. I don't want to write C, but I'm glad someone else does so I get the benefits when I write Ruby.
I don't understand how you can say Java, C++, and Ruby in the same breath. They are not at all alike. Also what optimizations are available to C which are not in C++? C++ is (almost) a strict superset of C.
Rubinius' one (called RubySL) also includes some rewrites of standard libraries, that were originally written in C. And as you may know, Rubinius itself is just Ruby code to some extent.
Rubinius has been traditionally lagging behind in features (e.g. for a long time didn't implement 1.9 string encoding properly) and wasn't necessarily _that_ much faster.
Also, people that do want to work at the core of a language usually have knowledge of multiple and don't mind using C or any other implementation language.
Ruby stdlib is mostly written in Ruby, btw.
Still, with Rubinius 3.0 coming up, I'm very interested what is coming there.
Did anyone notice a popup box asking you if you "didn't find what you were looking for"?
it appeared almost automatically after I moved my mouse to close the tab... Are they doing some mouse tracking and looking for rapid movement off screen (to the top of the page)?
25 comments
[ 4.7 ms ] story [ 57.3 ms ] thread"My vague plan for Ruby GIL is 1) add more abstract concurrency e.g. actors 2) add warning when using threads directly 3) then remove GIL"
Though in the case of CPython most of the cost comes from the refcounting. MRI is not refcounted so the performance hit of finer locking would probably be lower.
[0] http://dabeaz.blogspot.be/2011/08/inside-look-at-gil-removal...
There's also the fact that because of slow startup times, the modify/test cycle can be quite frustrating compared to working with MRI.
The truth is that the vast majority of ruby applications never reach a point where the steady-state post-warmup performance of jruby with pure ruby outweighs the fast-startup moderate performance of mri+cexts. And ones that do reach that point often have a better case for moving to something else anyways (including other jvm technologies that can now be shimmed on via jruby and eventually replace the whole thing).
What you + the jruby team is doing is truly awesome, at some point I'll have to try my hand at contributing to it :)
Memory usage and startup time are comparable to MRI - http://www.oracle.com/technetwork/java/jvmls2013wimmer-20140... see slide 19.
If you want to contribute there are beginner bugs (admittedly you need to be a fairly confident beginner) at https://github.com/jruby/jruby/issues?q=is%3Aopen+is%3Aissue....
Jruby + truffle + cext, however is becoming a possibility.
http://www.chrisseaton.com/rubytruffle/cext/
I haven't looked deeply, but this seems like something where the edge cases will be tricky, though.
Slightly of topic, but can anyone with better knowledge then myself of ruby implementations and internals explain why it hasn't caught much of a following (what it seems anyway, I may be wrong here).
To me it seems like a pretty good idea to implement Ruby mostly in Ruby, since it makes it easier to get contributions (especially to less performance-sensitive parts of the language, e.g. parts of the standard lib).
https://github.com/ruby/ruby/tree/trunk/lib
Rubinius' one (called RubySL) also includes some rewrites of standard libraries, that were originally written in C. And as you may know, Rubinius itself is just Ruby code to some extent.
https://github.com/rubysl
mruby has some Ruby code, too. Even some parts of the core language are written in it.
https://github.com/mruby/mruby/tree/master/mrblib
Also, people that do want to work at the core of a language usually have knowledge of multiple and don't mind using C or any other implementation language.
Ruby stdlib is mostly written in Ruby, btw.
Still, with Rubinius 3.0 coming up, I'm very interested what is coming there.
Disclaimer: it's linked in the omniref.com page too.
it appeared almost automatically after I moved my mouse to close the tab... Are they doing some mouse tracking and looking for rapid movement off screen (to the top of the page)?
If so, that's really cool. If not, nevermind
Glad I wasn't crazy