Live data from Hacker News

How to Fix Slow Code in Ruby

engineering.shopify.com

41–50 of 213 posts

Re: How to Fix Slow Code in Ruby

#42

I wish we could just take Ruby, scrap it, and as a community replace it with Crystal Lang

Why?

Because crystal lang has all of the main syntax and features that people love about Ruby, but it's way faster because of the typing and compiling.

"Fast as C, slick as ruby"

Re: How to Fix Slow Code in Ruby

#44
post #40

Earlier quoted context omitted.

Yes TruffleRuby struggles to run test code because it works against the optimisations we add to make production code fast. For example when you add more profiling to better optimise the hot code it makes the cold code slower, and tests are almost all cold code. Also our C extension emulation layer used to be extraordinarily slow while we made it work correctly, and it's still rather slow. It's a challenge but we're w…

Amazing work and really appreciate all you're doing to better the ecosystem. Question: (a) do you believe we'll ever get to a day when TruffleRuby/Graal will be able to 100% run Ruby on Rails and (b) how much faster over MRI do you believe it could achieve?

Compatibility yeah I don't think there's any reason we can't be very close to 100% there.

For parts of the Ruby ecosystem running production workloads, such as the Liquid template engine, I see 6x performance today. I think that's a realistic goal in time.

Re: How to Fix Slow Code in Ruby

#46
post #37

Earlier quoted context omitted.

I've seen conflicting benchmarks on this showing different results - possibly has changed over time, or run different comparisons. What you linked seems current at least.

Also keep in mind that as far as performance of dynamic languages goes, all of the P* languages (Perl, Python, PHP, and... Ruby ;)) have been left in the dust by the front-runners (eg Node.js or LuaJIT). Perl used to be king a long time ago, eventually, PHP took pole position, and maybe now it's Ruby's time to shine. But being leader of that particular pack could mean you're nevertheless still 'slow' depending on con…

I wouldn't put node in with luajit. Luajit is about 4x faster than v8 JavaScript. So it's still in the slow category

Re: How to Fix Slow Code in Ruby

#48
...Rewrite in almost anything else and you'll have fast code. :)

It's quite amazing the lengths the companies will go to just to avoid changing their status quo. But for them it makes sense.

---

EDIT: Downvoters, calm down. Ruby on Rails is objectively quite a slow framework and this is proven in many public benchmarks (Techempower included). And Ruby isn't the fastest among the dynamic languages either.

Less cargo culting and more facts, please.

Re: How to Fix Slow Code in Ruby

#49
post #15

What's current state on GraalVM as it relates to running production Ruby code? From what I understand, it's the fastest VM out there at the moment for Ruby. And yes, it's from Oracle but they have GPL'd the code [2] [1] https://www.graalvm.org [2] https://www.graalvm.org/docs/faq/ Edit: looks like TruffleRuby is built onto of Graal. https://github.com/oracle/truffleruby

Is it capable to run Rails?

Re: How to Fix Slow Code in Ruby

#50

Earlier quoted context omitted.

Basically do not use Ruby

Yes, Ruby is meant to be easy and magical, but it was never meant to be fast. It's fast enough for most things, but you also wouldn't show up to a drag race with a tuned bicycle.

https://crystal-lang.org/ almost the same as ruby. Blazing fast.
Post reply on HN