Earlier quoted context omitted.
Basically do not use Ruby
How is it that Python is able to do so many things quickly (even excluding NumPy/SciPy)? Is it more native code libraries? Could Ruby follow this path as effectively?
How to Fix Slow Code in Ruby
71–80 of 213 posts
Re: How to Fix Slow Code in Ruby
#72I wish we could just take Ruby, scrap it, and as a community replace it with Crystal Lang
That was probably a particularly lopsided comparison: lots of CSV and JSON reading, string-mangling, and writing back; it was using Python stdlib functions only, and numpy and similar would have also helped enormously. But I do regularly get factor 100x with all sorts of tasks compared to ruby of python.
That said, Ruby's console (or Pry) is without equivalent in Crystal, and I tend to do most everything on the cli in it. And, as someone already pointed out, the compile cycle is too slow. I've also noticed that even with practice, the intricacies of the type system do slow me down by maybe 30% or so? And the currently existing frameworks are still far away from the ease of whipping up an interface to whatever data you have lying around that Rails offers.
Re: How to Fix Slow Code in Ruby
#73Earlier quoted context omitted.
> services running those caches and persistence will not be written in ruby So what? What's wrong with using software like redis for cache, for a very small (but important) part of your business? I bet java apps use redis as well, and redis isn't written in java. So?
Is this an honest question? I honestly can't tell and I am not saying it to show disrespect -- just wondering if you are sarcastic. Erlang/Elixir have built-in caches that respond in the matter of 30-150 nanoseconds. Why would you need an external service for that? It's adding complexity -- and likely hosting costs. Isn't it self-evident to you that adding Redis as a caching layer to your stack is a bandaid to a deep…
What's the name of the concept and where in the typical stack does it fit? Is this https://blog.appsignal.com/2019/11/12/caching-with-elixir-an... or something else? Care to share a few link to docs/articles? Thanks.
Re: How to Fix Slow Code in Ruby
#74Benchmarks are subjective, but all benchmarks show Ruby as slower than compared dynamic languages. The relative speed difference is different per benchmark, but across the board Ruby is slower. It fundamentally has to be slower. Ruby is the most dynamic of the dynamic programming languages. And the community has embraced metaprogramming, making it every more dynamic. Especially on webservers, you'll be executing hund…
The article doesn't even discuss benchmarking Ruby against other languages, so I'm not really sure what you're on about. Couldn't resist taking a performance jab at Rails? Also, I'll take "double the hardware specs" if it means I'm actually able to focus on what I'm building and not dicking around with devops or rebuilding all of stuff Rails metaprograms for me by hand. If there was a framework for being as productiv…
Re: How to Fix Slow Code in Ruby
#75Seriously, if you need high performance out of the box, you should probably just skip Ruby. I love that language to death but most of the time you cannot use of it for a decent scale.
Same for me with Elixir. I love that little thing so much but there are workloads where it objectively shouldn't be used -- for web apps it's definitely one of the best picks out there but that's a different topic. I've lately been writing several Rust tools and mini apps and have admitted to myself that even if a language stack clicks with you almost perfectly, you should still reach out to other tools when appropri…
Re: How to Fix Slow Code in Ruby
#76There's a myriad of tools out there for profiling, some language specific, some not. Learn at least one of them well, how to read flamegraphs and how to benchmark properly (warmup code, synthetic vs real traffic, etc). There's definitely a jump between making guesses and hoping you improve performance vs truly understanding what your code is doing.
Re: How to Fix Slow Code in Ruby
#77Earlier quoted context omitted.
The article doesn't even discuss benchmarking Ruby against other languages, so I'm not really sure what you're on about. Couldn't resist taking a performance jab at Rails? Also, I'll take "double the hardware specs" if it means I'm actually able to focus on what I'm building and not dicking around with devops or rebuilding all of stuff Rails metaprograms for me by hand. If there was a framework for being as productiv…
> Also, I'll take "double the hardware specs" if it means I'm actually able to focus on what I'm building and not dicking around with devops or rebuilding all of stuff Rails metaprograms for me by hand. Try 7x to 11x. That's the amount of reduced RAM usage -- and the amount of increased accommodated users -- on identical hosting by the two apps I rewrote from Rails to Phoenix. > If there was a framework for being as…
$ rails c
Loading production environment (Rails 5.2.0)
[1] pry(main)> s = Subscriber.find_by_email('xyz@abc.com')
=> # s.expires_on += 2.months
=> Wed, 15 Jul 2020 14:10:19 UTC +00:00
[3] pry(main)> s.save!
=> true
It is done now! Good luck! Bye! - end of call.Cargo culting? From whom? I don't give a sh*.
Re: How to Fix Slow Code in Ruby
#78Earlier quoted context omitted.
Is this an honest question? I honestly can't tell and I am not saying it to show disrespect -- just wondering if you are sarcastic. Erlang/Elixir have built-in caches that respond in the matter of 30-150 nanoseconds. Why would you need an external service for that? It's adding complexity -- and likely hosting costs. Isn't it self-evident to you that adding Redis as a caching layer to your stack is a bandaid to a deep…
Interesting but not surprising; I'm being regularly pleasantly surprised by the Erlang/Elixir ecosystem :) . Can you precise what you're talking about when you say "Erlang/Elixir have built-in caches" ? What's the name of the concept and where in the typical stack does it fit? Is this https://blog.appsignal.com/2019/11/12/caching-with-elixir-an... or something else? Care to share a few link to docs/articles? Thanks.
There are libraries that combine Erlang/Elixir's caching mechanisms in an attempt to achieve the best performance for most scenarios[1] as well.
Technically, ETS is not perfect because it copies data from its mutable cache to the process that requests it. But it's still orders of magnitude faster than outsourcing that to Redis.
Re: How to Fix Slow Code in Ruby
#79Earlier quoted context omitted.
The article doesn't even discuss benchmarking Ruby against other languages, so I'm not really sure what you're on about. Couldn't resist taking a performance jab at Rails? Also, I'll take "double the hardware specs" if it means I'm actually able to focus on what I'm building and not dicking around with devops or rebuilding all of stuff Rails metaprograms for me by hand. If there was a framework for being as productiv…
> Also, I'll take "double the hardware specs" if it means I'm actually able to focus on what I'm building and not dicking around with devops or rebuilding all of stuff Rails metaprograms for me by hand. Try 7x to 11x. That's the amount of reduced RAM usage -- and the amount of increased accommodated users -- on identical hosting by the two apps I rewrote from Rails to Phoenix. > If there was a framework for being as…
> There are a number of web frameworks that perform much better than Rails
If you're measuring hardware loads and busting out your stopwatch to measure response times, then sure.
Bottom line is, there are plenty of good reasons to choose Rails over Phoenix. If you want to label choosing a well-backed framework with an incredibly mature ecosystem "cargo culting" then by all means.
Have fun writing Ecto queries by hand, wiring up document storage on your own, trying to find a standout auth library of choice like devise, finding a library that makes managing database views less of a pain, wiring up end-to-end system testing.
I'll be over here running rails new, wiring up sidekiq to ActiveJob, and building shit with ease.
Re: How to Fix Slow Code in Ruby
#80Earlier quoted context omitted.
> Also, I'll take "double the hardware specs" if it means I'm actually able to focus on what I'm building and not dicking around with devops or rebuilding all of stuff Rails metaprograms for me by hand. Try 7x to 11x. That's the amount of reduced RAM usage -- and the amount of increased accommodated users -- on identical hosting by the two apps I rewrote from Rails to Phoenix. > If there was a framework for being as…
When my small SaaS customer calls and asks for an extra extension at current hard times, then all I need is to open up Rails production console (pry) and live type in an ad-hoc code with auto-completion aid: $ rails c Loading production environment (Rails 5.2.0) [1] pry(main)> s = Subscriber.find_by_email('xyz@abc.com') => # s.expires_on += 2.months => Wed, 15 Jul 2020 14:10:19 UTC +00:00 [3] pry(main)> s.save! => tr…
What you describe is not exclusive to Rails.