11 ms·
Ruby 2.6.0-preview2 released with JIT
- alberth 8y agoWhat’s the current sentiment as for what will ultimately lead to the best performance of executing Ruby? From my uneducated perspective, seems like Graal VM could become the de facto Ruby deployment stack. https://github.com/oracle/truffleruby https://github.com/oracle/truffleruby
- sandGorgon 8y agoSame question here. Will truffle also be benefited with the changes made in 2.6 ?
- onli 8y agoI doubt that there are that many people that would allow Oracle tech to enter into a beloved language like Ruby, or the ecosystem.
- alberth 8y agoWhy not? Graal is EPL, GPLv2, LGPL licensed. https://news.ycombinator.com/item?id=16862130 https://news.ycombinator.com/item?id=16862130
- nirvdrum 8y agoFYI, what you've linked to is a breakdown for the licenses of various projects comprising GraalVM. The licenses you listed only apply apply to TruffleRuby. Having said that, Graal and its related projects are all open source, with a license listing available in its README: https://github.com/oracle/graal/blob/master/README.md https://github.com/oracle/graal/blob/master/README.md
- onli 8y agoBecause Oracle is Oracle, the most evil company in tech, the one most blatantly greedy. Look at what they pulled with Google. Oracle would wait till the tech usage grows and then use patents and API copyrights or whatever else they invent out of thin air to go after the players using its tech. The free license of Graal does not protect you from that, GPL2 specifically not. See https://www.gnu.org/licenses/rms-why-gplv3.en.html https://www.gnu.org/licenses/rms-why-gplv3.en.html.
- pjmlp 8y agoGoogle abused Sun, took advantage that they were in a critical financial situation not able to sue, and when they crashed, did not move a finger to rescue the company assets. Now Android has Google's own J++, limiting what kind of Java libraries are portable to the platform. At the same time, some OEMs are adopting Android instead of Embedded Java, thus increasing the fragmentation about what Java libraries are actually portable. Google just though they could let Sun close doors and get away with how they created their own J++.
- onli 8y agoThat's Oracle propaganda. Sun was perfectly happy with Google using Java and the free entry into the mobile market they got from that. See https://www.zdnet.com/article/a-google-android-and-java-history-lesson/ https://www.zdnet.com/article/a-google-android-and-java-hist..., https://www.zdnet.com/article/sun-ceo-explicitly-endorsed-javas-use-in-android-what-do-you-say-now-oracle/ https://www.zdnet.com/article/sun-ceo-explicitly-endorsed-ja....
- pjmlp 8y agoThat is Google propaganda. Sun did what they could to save their face. "Triangulation 245: James Gosling" https://www.youtube.com/watch?v=ZYw3X4RZv6Y&feature=youtu.be&t=57m42s https://www.youtube.com/watch?v=ZYw3X4RZv6Y&feature=youtu.be... Also doesn't change the fact that even with Android 8.1, I as Java developer cannot take a random jar from Maven Central and be certain it won't crash and burn on Android, regardless of the version.
- mixedCase 8y agoWhere you're seeing Oracle tech I see free software licensed under the LGPL. There's no way that if TruffleRuby becomes well and truly popular and Oracle decides to... be Oracle, no other company would pick up the banner. Ruby is just too popular for that not to happen.
- ksec 8y agoJava, or OpenJDK is fully open sourced and GPL. I asked multiple times what are the risk in using it. And no one ever had an answer for it. If the communities doesn't like where things are going, they could fork the whole thing and call it something else, like Coffee.
- karag 8y agowhy ruby innovate and not python ?
- _ZeD_ 8y agowhy not both? and btw, you may look at pypy if you like this kind of innovations
- geofft 8y agoIn fact, one of the oldest JITted Ruby implementations is Topaz, which was built on top of PyPy (i.e., it's a Python program that uses the PyPy infrastructure to parse/JIT/run Ruby instead of Python).
- blattimwind 8y agoCython has/had a mode of operation where it would attempt to compile any module thats imported at runtime, which sound fairly similar to this.
- sametmax 8y agoPyscho, Pypy, pyjion...
- blattimwind 8y ago> Unlike ordinary JIT compilers for other languages, Ruby’s JIT compiler does JIT compilation in a unique way, which prints C code to a disk and spawns common C compiler process to generate native cod e. Oh dear god.
- pavanky 8y agoWhy aren't they using LLVM :-/
- bastawhiz 8y agoThey answer this on the github: > Unstable interfaces. An LLVM JIT is already used by Rubicon. A lot of efforts in preparation of code used by RTL insns (an environment) https://github.com/vnmakarov/ruby/tree/rtl_mjit_branch#a-few-possible-approaches-in-jit-implementation https://github.com/vnmakarov/ruby/tree/rtl_mjit_branch#a-few...
- jashmatthews 8y agoThe new Ruby method JIT can use either GCC or clang as the backend. It uses C as an intermediate representation.
- Twirrim 8y agollvm isn't always available, doesn't support as many architectures and doesn't always give the best performance. The *nix philosophy has long been towards trying to provide choice wherever possible, so that people can use the tool that best meets their needs.
- my123 8y agoSame as the last stage of the SQL Server query optimizer then. (hey MS)
- make3 8y agothat's also what Theano did
- tbodt 8y ago
- wwarner 8y agoA standardized AST! That's a big win.
- twelvechairs 8y agoI would agree but concerned on this > Compatibility of the structure of AST nodes are not guaranteed. Not sure if it means its going to be any more stable/complete than ruby_parser / ruby2ruby
- pjungwir 8y agoCongratulations Ruby team! I'm excited to hear about the performance improvements. It seems like JIT could be a huge win since calling a method requires checking all kinds of possibilities that are almost always not used, but might be. I would love to keep all the power & fun of Ruby without worrying so much about performance. Speaking of optimizing method calls: now that it's been a few years, I wonder what Ruby folks think about refinements. Are you using them? Are they helpful? Horrible? I remember reading from the JRuby folks that refinements would make Ruby method calls slower---and not just refined calls, but all method calls [1], although it sounds like that changed some before they were released [2]. It seems like people stopped talking about this after they came out, so I'm wondering if refinements are still a challenge when optimizing Ruby? I guess MRI JIT will face the same challenges as the Java implementation? [1] http://blog.headius.com/2012/11/refining-ruby.html http://blog.headius.com/2012/11/refining-ruby.html [2] https://github.com/jruby/jruby/issues/1062 https://github.com/jruby/jruby/issues/1062
- chrisseaton 8y agoRefinements don't add any peak performance overhead in their final implementation.
- pjungwir 8y agoThat is great to hear! I'd love to read the details if you happen to have a link to more information. I've tried Googling for it a few times over the years but never found anything.
- chrisseaton 8y agoI haven't done any work to implement refinements myself, but I do know that basically it came down to something that you could write an inline cache against, guarded against the class version, so a simple word guard that you were doing anyway when you called any method.
- Rafert 8y agoI feel refinements are best suited for libraries. E.g. compare this improvement to the CSV gem: https://github.com/ruby/csv/pull/30 https://github.com/ruby/csv/pull/30 which defines it only for itself, compared to ActiveSupport defining it globally: https://github.com/rails/rails/commit/575dbeeefcaafeb566afc07cdd8b55603b698d9f https://github.com/rails/rails/commit/575dbeeefcaafeb566afc0...
- sho 8y ago> We’re going to implement method iniling in JIT compiler, which is expected to increase Ruby’s performance in order of magnitude An order of magnitude as in .. 10x? This seems too good to be true. Half the arguments against Rails melt away like butter if that's truly the case. Anyone with a better understanding of the details care to comment on the likelihood of these performance gains being actually realised, and if not, what we might realistically expect?
- sudhirj 8y agoFor hot code, probably, not the entire language in general. If you're looping through a million numbers doing the same calculation, or maybe rendering markdown in a loop an a lot of text, might hit 10X - the JIT will essentially write the code in C for you, then compile it and run it instead of Ruby.
- jashmatthews 8y agoAnother factor is a lot of the hot code, like JSON serialization, DB clients, HTTP parsing, is all already in native C extensions. Performance there is only going to improve a little, although some can be better off as pure Ruby + JIT.
- himom 8y agoRubinius uses LLVM IR for this. The only problem is rbx is still very slow on startup and interactive use. Ruby (MRI) will have to reinvent the wheel in order to get a panoply of optimizations that some very smart people have already baked in: like the ability to target almost any platform from the same library.. GCC requires cross-compiling per target.
- jashmatthews 8y agoDidn't Rubinius deprecate their JIT due to a torrent of issues and bugs and have not yet replaced it? Or am I out of date?
- 8y ago
- stevebmark 8y agoEverything in Ruby happens at runtime. Even the definition `class X` becomes a runtime `Class.new` invocation. It's imperative from the inside out. Even a JIT is compiler won't and can't solve the fundamental flaws permanently baked into the language. If you want performance, Ruby probably shouldn't be the first tool you reach for.
- stouset 8y agoThis isn’t a flaw. It’s a tradeoff. And one that buys an incredibly useful amount of flexibility.
- stevebmark 8y agoIt's a "tradeoff" in the way that not writing tests is a tradeoff
- sametmax 8y agoSure. Let's write a script, a website or analyse bio data together. You pick a static language. I'll pick a dynamic one. See you tomorrow.
- stevebmark 8y agoWhile my main concerns about Ruby aren't directly related to type systems or static typing, at this point in my career, the speed at which I can hack out a script in a language in 24 hours isn't related to how well designed I think the language is.
- jashmatthews 8y agoTruffleRuby + Graal brings full Java equivalent JVM performance to Ruby. It can even AOT compile a class definition like you described as impossible by using Partial Evaluation. Oracle's plan for world domination via JVM is completely changing the performance landscape for dynamic languages.
- himom 8y agoI wish though, that except for eval and exec, that the majority of Ruby code could get an incremental/LTO JIT similar to HotSpot and a GC like C4 rather than an inc gen GC.
- jaequery 8y agoI wonder if Matz may consider even just adopting Crystal in the future, considering it is almost 99% compatible with Ruby and has 10x-20x performance gains out of the box.
- jashmatthews 8y agoCrystal is far less compatible with Ruby than that. Simple methods/classes are valid but everything after that is completely different.
- TeddyDD 8y agoThis. Some concepts and syntax are similar but they are quite different. I'm not saying that in negative sense - static typing with type inference rocks.
- chrisseaton 8y ago> I wonder if Matz may consider even just adopting Crystal in the future, considering it is almost 99% compatible with Ruby This isn't even remotely true. Crystal syntax looks like Ruby. Crystal's semantics (the bit that matters) are not like Ruby.
- hirundo 8y ago> Add a new alias then to Kernel#yield_self. [Feature #14594] It might seem strange that they lead with this new feature, but `yield_self` can greatly improve the Ruby chainsaw, and `then` makes it more accessible. The style of writing a Ruby method as series of chained statements has a non-trivial effect on readability and conciseness. `then` lets you stick an arbitrary function anywhere in the chain. They become more flexible and composable, with less need to interrupt them with intermediate variables that break the flow. I've been using `ergo` from Ruby Facets for years ... largely the same thing ... and the more I used it the more readable I find my old code now. Funny how adding one very simple method can have more effect than so many other complex, high effort changes.
- paublyrne 8y agoI really would have preferred `pipe` as an alias.
- atombender 8y agoGood article about yield_self: https://zverok.github.io/blog/2018-01-24-yield_self.html https://zverok.github.io/blog/2018-01-24-yield_self.html
- virtualwhys 8y ago@darkdimius[0], the person who tweeted the referenced tweet in the article, was arguably the primary contributor to Dotty[1] behind Martin Odersky (Dotty will be Scala 3, the next major version of the language). Once he finished his doctorate at the EPFL, off to Stripe he went, bye bye Scala. Tough industry, on the one hand Scala benefits from a revolving door of high level EPFL doctoral students, and on the other the talent pool shifts around as students come and go. Money talks, companies like Stripe have a leg up in that they can fund full-time engineers to work on projects, whereas institution backed projects typically have a much smaller pool of long-term engineers to rely on (JetBrains, for example, has something like 40 full-time engineers working on Kotlin/KotlinJS/Kotlin Native). [0] https://github.com/DarkDimius https://github.com/DarkDimius [1] https://github.com/lampepfl/dotty https://github.com/lampepfl/dotty
- ksec 8y agoThere is another announcement from RubyKaigi 2018 related to performance. Rubex - A Ruby-like language for writing Ruby C extensions. https://github.com/SciRuby/rubex https://github.com/SciRuby/rubex