r/ruby • u/balloob • Nov 20 '15
Ruby 3x3: Ruby 3 will be 3 times faster
http://engineering.appfolio.com/appfolio-engineering/2015/11/18/ruby-3x39
u/pkmiec Nov 20 '15
We seem to be missing a good set of macro benchmarks for Ruby (and Rails). We have isrubyfastyet.com, which tries to benchmark simple Rails application but doesn't track JRuby / RBX very well and it's benchmarks could be improved. We have http://jruby.org/bench9000/ which is a set of micro benchmark.
I am excited about https://rubybench.org/ and the support for it by RubyTogether.org.
@headius, are you guys involved in this effort as well?
1
u/moomaka Nov 21 '15
We seem to be missing a good set of macro benchmarks for Ruby (and Rails)
1
1
u/nateberkopec Puma maintainer Nov 22 '15
Worth noting that, although the code for running those benchmarks is open and we can totally go fix it, the Rails implementations could totally be optimized much further. I don't think they're even properly utilizing all of the available cores.
26
u/headius JRuby guy Nov 20 '15
If you want 3x faster Ruby today, just use JRuby :-D
Seriously though, best of luck to MRI on this goal. We all want to see a faster standard impl.
4
Nov 20 '15
What is the memory consumption like deploying a Rails app in JRuby vs MRI/YARV?
Not just with single large apps, but also deploying numerous small apps, agency-style.
2
u/moomaka Nov 21 '15
If you want 3x faster Ruby today, just use JRuby :-D
Caveat: For some workloads.
-1
u/gordonisadog Nov 20 '15
Or better yet, use Rubinius
19
u/headius JRuby guy Nov 20 '15
Or better yet, actually benchmark and see which one's faster. You might be surprised.
-1
Nov 20 '15
jruby isn't (much, if at all) faster, though it is more efficient.
10
u/yxhuvud Nov 20 '15
[Citation needed]. Somehow Headius seems a bit more credible when it comes to claims like that..
7
u/FooBarWidget Nov 20 '15
The answer is... complicated. JRuby wins many benchmarks, and all the small microbenchmark programs I've written are massively in JRuby's favor as long as I ignore warmup time. But if we look at Rails, a major use case, then the speedup in practice is limited at best. And one major issue is that JRuby is very slow at dev. Just starting the Rails process takes half a minute vs something like 5 seconds on MRI.
Not discounting Charles Nutter's excellent work of course. I'm sure a lot of these problems are caused by either Rails or the JVM.
9
u/headius JRuby guy Nov 20 '15
See --dev flag for helping with local dev...it can improve startup 50% for most cases. We are continuing to research and work on other ways to improve startup time.
For production performance of e.g. Rails, most of the perf is lost in external libraries like our ActiveRecord adapters. JRuby + Rails + Sequel, for example, is very fast...much faster than MRI. We continue to try to improve our AR support but it's a big, complicated, inefficient library.
1
0
2
5
10
u/Harmenian Nov 20 '15
GIL: MRI has something called a global interpreter lock (GIL). It's a lock around the execution of Ruby code. This means that in a multi-threaded context, only one thread can execute Ruby code at any one time.
from: http://www.jstorimer.com/blogs/workingwithcode/8085491-nobody-understands-the-gil
and
MRI: Matz's Ruby Interpreter or Ruby MRI (also called CRuby) is the reference implementation of the Ruby programming language
7
u/headius JRuby guy Nov 20 '15
Also see Jerry D'Antonio's excellent RubyConf 2015 talk "Everything You Know About The GIL Is Wrong", which should get posted online by Confreaks very soon.
2
u/wbsgrepit Nov 20 '15
The IBM work on J9 seems like it could be a great basis for finally killing off GIL -- they have pulled out thead support from jvm into a poly vm that is meant to support just about any language. I am sure it will be a huge lift but with that support it may just become possible to take most of those GIL protections down to a sensible non thread blocking system.
8
2
u/matthewblott Nov 21 '15
Interesting discussion. A couple of minor points - JIT compilation is becoming a standard for higher level languages so it really makes sense for the official Ruby compiler to go down this road. As mentioned Ruby possibly suffers from not having a big corporate backer. Personally as a .NET guy and with their platform being open sourced I'd really love to see the IronRuby project resurrected, I've been saying for some time the platform needs more languages. Python's Guido is working 'Pyston', an open source JIT compiler sponsored by DropBox which is currently being used in production. It's still alpha but some of the benchmarks are quite impressive already - Ruby doesn't want to get left behind.
2
u/pavlik_enemy Nov 20 '15 edited Nov 20 '15
It's impossible to achieve this goal without backing by tech giants as correctly stated in the article. But none of them showed any desire to do it, Twitter preferred to switch from Ruby to Scala for their HTTP front-end and there's no place for Ruby at back-end if we talking massive scale. Also, I don't think it's likely that any future tech giants will use Ruby - the best thing about Ruby is Rails and it's a bit dated. It's good for an application with lots of forms and relational storage but doesn't work that well when you need server push and non-blocking I/O. BTW, Python is heavily used at Google, did it became three times faster?
9
u/headius JRuby guy Nov 20 '15
Both Python and Ruby have core design issues that will forever limit their performance. In Ruby's case, it's the pervasive use of direct pointers in C extensions that prevents better GC, parallel execution, and optimizing JIT from working as well as they could. They might be able to achieve 3x but it's going to be a lot of work.
2
u/cjlarose Nov 20 '15
It'd be nice to see more core support for asynchrony (e.g. single-threaded event-loop) in Ruby Core. I know there's eventmachine, but adoption isn't great. Python added asyncio in 3.4 and as a result the community is writing more async code and making better use of a single thread of execution. It seems like a good way to squeeze more performance out of languages not designed with good concurrency support from the get-go.
2
u/realntl Nov 20 '15
I think the days of single threaded event loops are numbered, to be honest. They are far too prone to introduce undesirable coupling.
3
u/pavlik_enemy Nov 21 '15
It doesn't look like it. Node.js is very popular, Twitter introduced Finagle even though the threaded model works fine on JVM etc. Reactor based frameworks use less memory and maximize utilization and if the language has proper primitives, they aren't hard to use.
1
-8
u/iconoclaus Nov 20 '15
sorry to be a buzzkill but 3 times faster Ruby would still be an order of magnitude slower than fast languages. it won't boost its adoption. I'd love for the short term discussion of Ruby3 to be around concurrency and support for libraries relating to analytics and machine learning. or longer term plans to champion web assembly.
12
u/JohnBooty Nov 20 '15
Ruby can still be very, very productive and useful without being as fast as Go or C or assembly.
Since pretty much the dawn of computing we've had different languages for different things. The goal isn't for you to be able to write an operating system kernel in Ruby, or to replace C++. The goal is for Ruby to be a highly productive and expressive language.
8
u/iconoclaus Nov 20 '15
No debate there. I use Ruby almost exclusively. But speed isn't a priority because there's plenty of other languages we can resort to for faster subsystems.
10
Nov 20 '15 edited Nov 20 '15
That's what they used to say about javascript. And an order of magnitude is a stretch, Ruby is currently just as fast or faster than Python.
And is not 30 times slower than Java in most benchmarks.http://benchmarksgame.alioth.debian.org/u64q/ruby.html
http://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=yarv&lang2=java
1
u/iconoclaus Nov 21 '15
Python isn't something one would normally consider fast -- it gets routinely derided for being a snail. Or even Java for that matter. Take a look a look at the numbers coming out of Crystal (or the Phoenix framework from Elixir). Why not just use a slow Ruby + really fast Ruby-like languages? Why the obsession with making Ruby just a little bit faster (but still slow)?
2
Nov 21 '15 edited Nov 21 '15
Because it's useful.
Edit:I love elixir but it is not yet as useful as Ruby for most things.
14
u/moderately-extremist Nov 20 '15
3x may not be that much of a stretch - according to this article javascript performance jumped 10X when Google introduced V8, and has continued to increase since then.