News for hackers. Stuff that matters.
Re:Why Wasn't Ruby 3 Faster? by strken on Wednesday February 10, 2021 @08:41PM (#26097244)
On the last section, where he says people "weren't avoiding Ruby for speed reasons", that's only true if you take speed very literally. Ruby has concurrency problems compared to many of the more recently popular backend languages like JS, Go, Elixir, or even Java. It has single-threaded performance that's fast enough for a lot of things, but out of the box its ecosystem and standard libraries don't default to evented IO, and the GIL messes up threading, both of which can be footguns for anyone trying to build a resilient and scalable service.

When I was a junior engineer, one of our demos to a client failed because we had a group of 20 people try to use a server that had a highish latency connection to a database, and using synchronous IO meant that a 50ms db round trip for each executed query, with each request running maybe 5 or 10 queries, on a VM with 2 cores and one Rails process per core, would queue up incoming requests until they hit the 20 second mark and started timing out.

Bad concurrency because of evented IO is not exactly the same thing as being slow, but it manifests as much the same developer experience, so it gets misinterpreted and Ruby gets a reputation for being slow.

Re:Why Wasn't Ruby 3 Faster? by protomikron on Thursday February 11, 2021 @12:07AM (#26098434)
There is something seriously wrong with your number (struggling to serve 20 people).

I do not have experience with Ruby, but I think it's similar to Python (in performance) and even if it's let's say 5 times slower (which I don't think it is), a webservice on a simple machine (workstation) in Ruby can easily serve north to 1k (or more) requests per seconds (behind nginx or apache or whatever), and in no way would 20 users be a problem.

It doesn't matter if that's async or not (note, not being async does not rule out concurrency or parallelism), but there was something seriously wrong with your application (if you have to serve long-running tasks, you have to make a msg queue anyway and shouldn't do that in your HTTP response directly). You may gain from async if you are IO bound, but with 20 users you are not IO bound, believe me.

Re:Why Wasn't Ruby 3 Faster? by strken on Thursday February 11, 2021 @12:35AM (#26098583)
We were "IO-bound" using a setup that executed a maximum of two requests at a time, completely blocked processing new requests until earlier ones fully completed, and took a long time to execute requests because of unexpected latency in a dependency, while 20 frustrated users sat in a room hammering the refresh button and dumping more tasks onto the queue.

You're absolutely right when you say there was something seriously wrong with the setup! The problem is that it was more or less what you'd get if you set up a default Rails app behind Passenger, and Passenger did this because some of the major Ruby gems weren't threadsafe (e.g. Rails, until 2008), which comes back to concurrency problems with the ecosystem.

Re:Why Wasn't Ruby 3 Faster? by jacobsenscott on Thursday February 11, 2021 @01:39AM (#26098901)
If you were IO bound you could have run many more rails processes. There's no reason to limit your self to one process per core. You can run many times that number of processes since they are all just waiting on IO.
Re:Why Wasn't Ruby 3 Faster? by EdwardDiego on Thursday February 11, 2021 @04:32AM (#26099757)
I'm sure the original commenter is loving all your 20/20 hindsight.
Re:Why Wasn't Ruby 3 Faster? by coldtea on Thursday February 11, 2021 @05:33AM (#26100087)
The original commenter offered his story as an issue with Ruby preventing X.

The 20/20 hindsight is not meant to retroactively solve their problem, it's mean as a counter-argument, that the problem was their design, not Ruby.

Re:Why Wasn't Ruby 3 Faster? by Person5478 on Thursday February 11, 2021 @08:30AM (#26101256)
The posters point is that Ruby has surprising concurrency semantics compared to other solutions.
Re:Why Wasn't Ruby 3 Faster? by Evan__ on Thursday February 11, 2021 @09:47AM (#26101965)
It has the same concurrency semantics w/r/t IO as any other language that isn't using an event based runtime. If you wrote your app in C and used a single thread you'd have the exact same issue.
Re:Why Wasn't Ruby 3 Faster? by kevincox on Thursday February 11, 2021 @08:46AM (#26101428)
Ruby should be able to execute more than one request on a time because while it can only have one thread executing Ruby at a time it can run other threads while waiting for IO. It seems like for some reason Rails was limited to one thread which is not how it should be configured.
Re:Why Wasn't Ruby 3 Faster? by darwinwhy on Thursday February 11, 2021 @12:46AM (#26098636)
What is Passenger exactly? Never heard of it before now. A quick Google brings up a marketing page that doesn't explain much more.
Re:Why Wasn't Ruby 3 Faster? by ForHackernews on Thursday February 11, 2021 @03:49AM (#26099556)
It's an application server. If you're familiar with the Python webdev ecosystem, Passenger is roughly a Ruby equivalent for something like uWSGI or Gunicorn. (IIRC, you can actually run Python apps with Passenger now, too)
Re:Why Wasn't Ruby 3 Faster? by coldtea on Thursday February 11, 2021 @05:34AM (#26100091)
Where now = for 5 years or more.
Re:Why Wasn't Ruby 3 Faster? by universa1 on Thursday February 11, 2021 @03:08AM (#26099334)
Something like mod_perl / mod_xxx in the early days... and they did some work on the concurrency problems with rails and ruby around the ruby 1.8 days iirc... In the meantime they expanded to more languages...
Re:Why Wasn't Ruby 3 Faster? by e12e on Thursday February 11, 2021 @08:55AM (#26101510)
Not sure if you mean this page or not: https://www.phusionpassenger.com/ But as they say, it's an application server. Similar to mod_perl for apache/php, unicorn or indeed nodejs (which can function as an application server for Javascript).
Re:Why Wasn't Ruby 3 Faster? by johnmcauley on Thursday February 11, 2021 @01:18AM (#26098791)
It’s a Ruby web server that can we bed used with nginx or Apache.
Re:Why Wasn't Ruby 3 Faster? by xorcist on Thursday February 11, 2021 @02:38AM (#26099185)
We know nothing about the details, of course, but there's something fishy about the performance story. If I were to take a guess it sounds more like a problem with misconfigured software than having used fundamentally wrong tools for the job.

It sounds like the concurrency was set much too low. That's not limited to the configured max workers but there will be similar settings for the web server, database connection layer and the database itself.

A similar thing would have happened with C++ or Java if there was a connection pool of two and database queries that took 500 ms to complete. I've seen worse mistakes in producion code.

The lesson to learn from this is probably not that goroutines makes everything faster, but that you have to understand the tools you use. Also, test demos. And always keep a backup plan. That's what Steve Jobs did, relentlessly, for all his demos.

Re:Why Wasn't Ruby 3 Faster? by throwaway189262 on Thursday February 11, 2021 @04:32AM (#26099754)
He said there was high db latency. This matters a ton when your language is single threaded and not using async io. 20 queries would tie up the whole server for a second at 50ms db latency.

You can get around it by using async instead of blocking, using fibers which don't block, or using a thread pool so other threads can keep serving.

I'm not experienced with Ruby but it sounds like Ruby doesn't do any of those

Re:Why Wasn't Ruby 3 Faster? by dragonwriter on Thursday February 11, 2021 @04:40AM (#26099788)
> I'm not experienced with Ruby but it sounds like Ruby doesn't do any of those

Modern ruby can do any of those, though in 1.8 or earlier it could do fewer, and less well.

Re:Why Wasn't Ruby 3 Faster? by inopinatus on Thursday February 11, 2021 @08:44AM (#26101408)
Ruby does all of those things. The story sounds ancient, and even then a consequence of naive production design far more than any emergent property of language.
Re:Why Wasn't Ruby 3 Faster? by sciurus on Thursday February 11, 2021 @08:38AM (#26101341)
> You can get around it by using async instead of blocking, using fibers which don't block, or using a thread pool so other threads can keep serving.

The typical approach for Ruby, Python, and similar languages is just to run more processes.

Re:Why Wasn't Ruby 3 Faster? by throwaway189262 on Friday February 12, 2021 @07:03AM (#26112748)
Ah just like the 80's
Re:Why Wasn't Ruby 3 Faster? by dragonwriter on Thursday February 11, 2021 @12:06AM (#26098430)
> Ruby has concurrency problems [...] standard libraries don't default to evented IO, and the GIL messes up threading, both of which can be footguns for anyone trying to build a resilient and scalable service.

Yes, but this article is about speed, not concurrency, because speed is a thing 3.0 didn't do a major improvement to from the last 2.x release.

There's no need for a “Why didn't Ruby 3 improve concurrency/parallelism” article, because it did.

Fiber#scheduler addresses your IO issue, and Ractors (while still experimental) are aimed at the parallelism issue.

Re:Why Wasn't Ruby 3 Faster? by throwaway189262 on Thursday February 11, 2021 @04:26AM (#26099734)
Java's concurrency support is quite good. One of the best language level implementations I've used. It supports OS level threads and async. And they're adding support for fibers. At that point it will be the only mainstream language that supports all three popular models

JS has an equally bad concurrency story as Ruby. Maybe even worse. There are no threads, you can only use a single core per instance. In practice the problem is ram. JS already uses a lot of ram compared to Java and running an instance for each core makes it way worse.IMO only crazy people run JS backends when there's so many other similar options

Re:Why Wasn't Ruby 3 Faster? by jiofih on Thursday February 11, 2021 @05:01AM (#26099891)
> JS has an equally bad concurrency story as Ruby. Maybe even worse.

This is absolutely false. Yes, JS is single threaded, but all IO is async and happens via a worker pool. On top of that it is 3-10x faster than Ruby for most tasks due to the insane amount of development effort that went into the browser runtimes, it’s often within 50% of C speeds.

And then the entire ecosystem is async. This is why you’ll see JS frameworks near the top of TechEmpower benchmarks achieving massive concurrency numbers, and also why nobody recommends any kind of CPU-heavy workload in node.

Imagine Ruby came with Puma built-in, and all libraries only exported async interfaces.

Re:Why Wasn't Ruby 3 Faster? by zurn on Thursday February 11, 2021 @08:12AM (#26101085)
By JS do you mean Node here?

Node has both blocking and async versions of a lot of IO operations. But async IO is more commonly used certainly. The real question might be whether a thread pool backed async IO implementation makes your program do concurrent IO better than a GIL + blocking IO calls that release the GIL, it's not obvious to me.

(Doesn't Node have threads too nowadays?)

Re:Why Wasn't Ruby 3 Faster? by jiofih on Thursday February 11, 2021 @08:59AM (#26101543)
Almost no code uses node’s sync APIs unless explicitly asked to, its ingrained in developer practices to the same level as not polluting global scope.

Node’s threads are for cases you really want to do heavy computation without resorting to another language. All the I/O is still backed by LibUV and an event loop, threads don’t really offer any improvement there.

Re:Why Wasn't Ruby 3 Faster? by throwaway189262 on Thursday February 11, 2021 @05:28AM (#26100054)
Makes sense. Better than Ruby I guess. It's still not really concurrency, it just handles being single threaded better.

JS is strange because of all the optimization. It's technically multi threaded with IO but in a way that you only control the "main thread". Reminds me of old UI work

Re:Why Wasn't Ruby 3 Faster? by coldtea on Thursday February 11, 2021 @05:32AM (#26100078)
>It's still not really concurrency

Well, it also has Workers, which is.

Re:Why Wasn't Ruby 3 Faster? by jiofih on Thursday February 11, 2021 @09:08AM (#26101631)
Concurrency != parallelism. You can of course run a multi-process cluster, but that’s besides the point (and these days it’s best to run a single process inside orchestration like k8s).

Basically almost every high performing server atm is running on some form of event loop / cooperative multi-tasking. Ruby Puma, Gunicorn, rust’s tokio and async/await, goroutines... Java is probably the big exception here (if you’re not using VertX et al) and we all know the pain of thread safety.

Re:Why Wasn't Ruby 3 Faster? by throwaway189262 on Friday February 12, 2021 @06:58AM (#26112720)
Very true. Go is an exception, and some day Java will be as well. They're both going route of userspace threads instead of reactive API's, thankfully.
Re:Why Wasn't Ruby 3 Faster? by kungito on Thursday February 11, 2021 @08:02AM (#26101011)
C# has them all already. Java has been lagging behind C# for a long while
Re:Why Wasn't Ruby 3 Faster? by throwaway189262 on Friday February 12, 2021 @07:01AM (#26112736)
Java is very methodical about what features they add. Some of the sluggishness is intentional.

As far as threading, Java is adding userspace M:N threads which will be far superior in most use cases to C#'s async. And unlike async it gives an automatic performance boost to most existing code

C# has a long history of breaking changes. One of the reasons Java is more popular is 90% of decades old code runs fine on the newest version. Java's backwards compatibility is absolutely unmatched.

Re:Why Wasn't Ruby 3 Faster? by kaba0 on Thursday February 11, 2021 @07:07PM (#26109287)
Project Loom’s virtual threads will be superior to the random function coloring with async in C#. With it, you can write sync code and it will automatically change to another “fiber” when it hits IO or other blocking operation.
Re:Why Wasn't Ruby 3 Faster? by gray_-_wolf on Thursday February 11, 2021 @05:28AM (#26100055)
> When I was a junior engineer, one of our demos to a client failed because we had a group of 20 people try to use a server that had a highish latency connection to a database, and using synchronous IO meant that a 50ms db round trip for each executed query, with each request running maybe 5 or 10 queries, on a VM with 2 cores and one Rails process per core, would queue up incoming requests until they hit the 20 second mark and started timing out.

I'm fairly sure GIL is released when waiting for external I/O, at least all the decent C database libraries do so. So in your case threads would have help quite a bit.

In general yes, the GIL is imho a problem and I do not like it, but at the same time there are ways to configure applications so that they do not mind that much.

For non-thread safe things (are there still any?) there is always the goold old way of just running multiple processes (with preloading the memory usage of even 10, 15 puma workers is often acceptable).

Re:Why Wasn't Ruby 3 Faster? by vidarh on Thursday February 11, 2021 @03:51AM (#26099562)
So you hadn't load-tested, and had misconfigured Rails.

I really, really dislike Rails for any number of reasons, but not having spent the time to understand how to set it up is not Rails fault.

Re:Why Wasn't Ruby 3 Faster? by bzb6 on Thursday February 11, 2021 @04:20AM (#26099708)
Defaults matter.
Re:Why Wasn't Ruby 3 Faster? by WJW on Thursday February 11, 2021 @04:44AM (#26099805)
So does knowledge of your stack. Rails default settings are for development on one box, it expects you to look over the settings at least once before you push to prod. I can't blame Rails for not having "client demo for 20 people" as the default settings (and I also can't really blame GP for not thinking about Rails configuration too deeply as a junior engineer, that is on the more senior engineers on that team who apparently completely forgot to verify it worked before doing the demo).
Re:Why Wasn't Ruby 3 Faster? by tempest_ on Wednesday February 10, 2021 @09:35PM (#26097592)
This is the same reason I have been shifting away from python for anything more than a quick script.

Processors have only been going sideways for a while and python makes this a pain.

Elixir and Rust are a little less painful in that regard.

Re:Why Wasn't Ruby 3 Faster? by ketamine__ on Wednesday February 10, 2021 @08:56PM (#26097341)
Can you really blame Ruby when the project didn't have the right resources?

The team could have booted up more processes. Isn't that the answer?

Or have I misinterpreted your comment?

Re:Why Wasn't Ruby 3 Faster? by chmod775 on Wednesday February 10, 2021 @11:16PM (#26098201)
I think you have missed where he said it had 20 people using it.

Not 200,000. A single process wasn't able to handle 20.

You'll be hard pressed intentionally writing code that performs that slowly in a framework in another language.

Ruby by default has an incredibly long list of "you can but you shouldn't" and things you need to be aware of, especially around concurrency.

Other languages are mostly fast by default. When you follow some nodejs/express/whatever introduction tutorial and implement your first application in the most naive way possible, you'll end up with something that will easily scale to hundreds if not thousands of users out of the box.

Do the same with ruby (or even with some python frameworks, to be fair), and stuff can break at less than a hundred users.

And that's why yes, you can blame that on ruby. Or at least ruby how it is commonly taught.

Re:Why Wasn't Ruby 3 Faster? by jacobsenscott on Thursday February 11, 2021 @02:01AM (#26099002)
There's nothing about the code being slow in the example. The example said the processes were io bound. The speed of ruby code is irrelevant. If it was io bound demo system had 2 processes sitting 99% idle.

The example said there was 0.5 seconds of IO per request so each process could serve 2 requests per second. 2 processes would serve 4 requests per second. The mistake was running only one process per core. 10 processes would server 40 requests per second, and the cores would still be mostly idle. With rails you always run as many processes as memory allows, not one per core.

Now that rails is thread safe you can have each process run a few threads. If you ran 10 processes and 4 threads per process you are up to 120 requests per second.

If you really need massive concurrency that isn't anything special. But that is more than enough for 90% of the web apps out there.

Re:Why Wasn't Ruby 3 Faster? by the-dude on Thursday February 11, 2021 @04:40AM (#26099789)
This is nonsense, there is boatloads of frameworks and CMSes which can easily run into the 10s or 100s of milliseconds for the main request ( WP for example ).

Serving only 20 users only has to do with how many workers were assigned.

I actually implemented a high traffic RoR payment provider on minimal infra ( 1 small VPS ), and benchmarked a couple of Python CMSes and compared them to WP.

Re:Why Wasn't Ruby 3 Faster? by michaelcampbell on Thursday February 11, 2021 @08:43AM (#26101396)
> I actually implemented a high traffic RoR payment provider on minimal infra ( 1 small VPS ), and benchmarked a couple of Python CMSes and compared them to WP.

I'd like to see your results if you still have them.

Re:Why Wasn't Ruby 3 Faster? by ketamine__ on Wednesday February 10, 2021 @11:43PM (#26098326)
There is a lot we don't know with the example given. It's unfair to blame Ruby.
Re:Why Wasn't Ruby 3 Faster? by lostcolony on Thursday February 11, 2021 @12:07AM (#26098435)
But it's not unique to this example. It's common; if you don't start out concerned about concurrency in Ruby, and just do the naive thing, you are going to fall over at -extremely- low numbers compared with most other modern languages.
Re:Why Wasn't Ruby 3 Faster? by the-dude on Thursday February 11, 2021 @06:39AM (#26100464)
If it is so common as you claim, could you point us to some public examples of this?

I have never ever been concerned about concurrency in Ruby, or Python or PHP. Just deployed the number of workers which would be able to serve our peaks.

I do write high concurrency application though, but those are not web apps and are not written in these languages.

Re:Why Wasn't Ruby 3 Faster? by jmcgough on Thursday February 11, 2021 @06:56AM (#26100564)
I've used Ruby and rails for close to a decade and have never seen/experienced something like what they're describing, so I doubt this is really that common.
Re:Why Wasn't Ruby 3 Faster? by debaserab2 on Thursday February 11, 2021 @03:31AM (#26099461)
The "naive" thing in Ruby, if you're serving HTTP requests, is to use some kind of app gateway that allows concurrency, such as puma or unicorn. It's just not all that viable to do something more basic than that unless you're willing to write all the request handling stuff by hand.

That aside, a ruby script that can't handle 20 req/s on 2 vcpus seems rather suspect. I'd be really curious what that code looked like. I'm doubtful that it has much to do with the language and not the code design.

Re:Why Wasn't Ruby 3 Faster? by strken on Wednesday February 10, 2021 @10:02PM (#26097782)
You're absolutely right! The biggest things I learnt from that were:

- overprovision resources for big demos by a significant amount

- test your demo before you give it

- deploying pets (servers you ssh into and lovingly configure) instead of cattle (instance abc123 that's created automatically) means you can't scale them as easily

- if you have concerns about a big demo, particularly ones that could be fixed by spending $10 on EC2 instances, you should fix them yourself instead of emailing the tech lead and assuming he'll handle it

- spinning up processes with phusion passenger is awful[0] and we should have been using something threaded like puma

That being said, the same footguns apply at various points as you scale, because Ruby's GVL still exists, and because even though threads are lighter weight than processes, they're still relatively expensive to switch between and to maintain in memory compared to e.g. Go/Elixir lightweight threads or evented IO.

Unfortunately (or perhaps fortunately) the problems with threaded IO start applying well above 20 concurrent users, so I don't have any fun stories about failed demos involving Puma instead of Passenger.

[0] Specifically, Rails processes take up a lot of memory, none of it is shared, context switching between processes is pretty expensive, and so you're limited to a smaller number of processes that can become IO-bound very easily

Re:Why Wasn't Ruby 3 Faster? by jashmatthews on Wednesday February 10, 2021 @10:35PM (#26097988)
> Threads are lighter weight than processes they're still relatively expensive to switch between and to maintain in memory ... context switching between processes is pretty expensive

This is a really common misconception. Both switching between threads and processes is _extremely_ fast compared to what web applications do.

An exceptionally fast web response is generally <1ms. Linux thread context switching takes ~2 microseconds. Forking a new processes takes ~20 microseconds.

Re:Why Wasn't Ruby 3 Faster? by strken on Wednesday February 10, 2021 @11:07PM (#26098155)
Relatively expensive was probably not phrased well, but a goroutine context switch is ~200 nanoseconds and instantiating a new one takes ~1 microsecond, from memory and a quick google.
Re:Why Wasn't Ruby 3 Faster? by jashmatthews on Thursday February 11, 2021 @01:51AM (#26098946)
Doing nothing 10x as fast is not all that useful. In a real app it's unlikely the difference in context switching being 0.2% of your CPU time or 0.02% of your CPU time matters.

It's also not a fundamental restriction on threads vs Goroutines either. switchto is very nearly as fast a Goroutine context switching https://www.phoronix.com/scan.php?page=news_item&px=Google-U...

Re:Why Wasn't Ruby 3 Faster? by otabdeveloper4 on Thursday February 11, 2021 @02:01AM (#26099003)
> threads are lighter weight than processes, they're still relatively expensive to switch between and to maintain in memory compared to e.g. Go/Elixir lightweight threads or evented IO

Not true. Context switching pthreads is orders of magnitude faster than any Go/Elixir concurrency mechanism.

So-called "lightweight" threads exist to fix the concurrency problem with garbage collection in scripting languages. Without garbage collection pthreads are fast enough for any problem.

Re:Why Wasn't Ruby 3 Faster? by ramchip on Thursday February 11, 2021 @07:56AM (#26100972)
Lightweight threads in Erlang/Elixir were created as a unit of fault tolerance. A lightweight thread can suddenly exit when it hits an error, and the VM mechanisms give you guarantees that any resource it owned will be freed (memory, sockets, registered name, ETS tables, etc.) Using signals and monitors you can extend this to any other type of resources, for instance DB connections in an SQL adapter library.

That's the original advantage over OS threads.

Re:Why Wasn't Ruby 3 Faster? by otabdeveloper4 on Thursday February 11, 2021 @09:06AM (#26101606)
No, you don't need cooperative threads for this. Proper exception handling fixes this problem with OS threads for you.
Re:Why Wasn't Ruby 3 Faster? by ketamine__ on Wednesday February 10, 2021 @10:23PM (#26097910)
Passenger can be configured to restart processes after they reach a memory threshold.

Another optimization is using jemalloc. Going to try this soon with Sidekiq workers.

Re:Why Wasn't Ruby 3 Faster? by Railsify on Wednesday February 10, 2021 @09:10PM (#26097444)
This is the right answer. The demo failed because the dev team failed to understand the performance and scaling characteristics of the code they wrote. This was a failure of people, not technology.
Re:Why Wasn't Ruby 3 Faster? by josephg on Wednesday February 10, 2021 @09:33PM (#26097570)
Eh - it was a failure of the (people, technology) tuple. Different choices by the engineers on the team could have fixed that problem. And different technology choices by the engineers behind ruby (/rails) could also have fixed the problem. (Eg async io, much larger thread pools, etc).

Everyone dropped the concurrency ball hoping that was someone else's problem. Its the dev team's fault because everything is ultimately the dev team's fault. But it would also be great if it was fixed in ruby + ruby's ecosystem.

Re:Why Wasn't Ruby 3 Faster? by Railsify on Wednesday February 10, 2021 @11:18PM (#26098211)
If something is a known-known, you have to take personal responsibility when you don't take that thing into account and get bit. It's not appropriate to even mention some person you have not met as part of the reason a demo failed. Personal accountability it key in this industry, do your due diligence and events like were described will not happen.
Re:Why Wasn't Ruby 3 Faster? by dwrowe on Thursday February 11, 2021 @08:37AM (#26101332)
Easier to blame the seemingly nameless technology and completely change the conversation by using some other stack entirely that accounted for your lack of due diligence.
Re:Why Wasn't Ruby 3 Faster? by sanderjd on Wednesday February 10, 2021 @10:34PM (#26097980)
Yes but the point is that lots of people became disenchanted with ruby because it was notably harder to get this sort of thing right than it was for the alternatives with more built in support for in-process concurrency. Maybe it's not the case anymore, but back around 2010, the only people who knew what they needed to do to configure a rails app to scale decently were those who had battle scars of the kind in the parent comment. And nobody came out of those battles feeling all sunshine-and-roses about the platform.
Re:Why Wasn't Ruby 3 Faster? by jashmatthews on Wednesday February 10, 2021 @10:36PM (#26097995)
Ruby had support for in-process concurrency via threads for the last 14 years.
Re:Why Wasn't Ruby 3 Faster? by sanderjd on Wednesday February 10, 2021 @11:29PM (#26098269)
And yet, see the comment that started this thread. It is simply true that concurrency was a pain point for rails for a lot of people for a long time. (I don't know if it still is, I've been out of that game for five years.)
Re:Why Wasn't Ruby 3 Faster? by ReactiveJelly on Wednesday February 10, 2021 @09:44PM (#26097655)
By resources do you mean hardware resources or expertise or what?

Cause running more than 2 processes on a 2-core server just sounds weird.

I thought Node's doctrine was "One process per core", and (async) Rust and Go seem to do fine with managing their own thread pools. I haven't _tried_ to do a realistic benchmark of Hyper, but I've never seen it struggle with concurrency either, even on long-polling applications where concurrency was the norm for all clients.

More processes would work, but it doesn't seem like the right layer of abstraction for 2015, now that Nginx and Node have made the event model so popular.

Re:Why Wasn't Ruby 3 Faster? by ketamine__ on Wednesday February 10, 2021 @10:07PM (#26097811)
More hardware resources.

The example given was a Rails app. I don't think one process per core is common for Rails deployments but I'm not sure.

Re:Why Wasn't Ruby 3 Faster? by jashmatthews on Wednesday February 10, 2021 @10:42PM (#26098022)
Process per core with threading for parallel IO has been the default for almost a decade now.
Re:Why Wasn't Ruby 3 Faster? by ketamine__ on Wednesday February 10, 2021 @11:46PM (#26098343)
Default in what app servers?
Re:Why Wasn't Ruby 3 Faster? by jashmatthews on Thursday February 11, 2021 @01:52AM (#26098955)
Puma is part of the default Rails Gems and was first released all the way back in 2011.
Re:Why Wasn't Ruby 3 Faster? by pmontra on Thursday February 11, 2021 @01:45AM (#26098921)
What year was that? I had Rails applications running on a dual processor Pentium 3 in 2007. An online sailing game, no problems with performances.

It's hard to remember what we had to do back then, but Passenger was probably there. My first though: did you use a connection pool and a C driver to make parallel requests to the database?

Re:Why Wasn't Ruby 3 Faster? by ufmace on Thursday February 11, 2021 @01:24PM (#26105223)
Probably a little late to be second-guessing exactly what happened there, but a few comments anyways:

It's almost always worth doing some concurrency/scaling sanity checks on anything you're preparing to demo IME. There's plenty of ways any particular app, no matter what language or framework, could unexpectedly fall down when facing 20x traffic. If not from the language itself, perhaps from various external dependencies. It may be true, particularly at some previous times, that doing the most naive thing in Rails hosting was significantly worse than doing the most naive thing in Java hosting, but still, always worth checking.

The 50ms DB round-trip 10x per request smells funny. Most queries to a closely located DB with demo app data should be more like 5ms or faster. Maybe there's good reason for it to take so long, I'm not sure. Perhaps the DB also had some slowdown from so many of those queries being executed concurrently, or maybe it would have if you had had a faster Rails setup or used Java instead. All the more reason to always test it and not just assume it'll be fine because Java should be fast.

Each individual web request is still gonna be rather slow if it's gotta do multiple 50ms DB round trips. I don't know Java that well, but C# and Ruby both have pretty decent tools for making that IO concurrent in the scope of an individual request. You have to deliberately use it though, since only you know which queries actually depend on data from other queries.

I've been working professionally with Rails for several years. If I was deploying such an app now, it'd be simple and fast to say, I suppose I'll serve it with Puma. 2 cores, so 2 processes. 5-10 threads per process is pretty normal, maybe make it 20 here since I expect a lot of time waiting on DB IO. Now we've got 40 workers and it ought to serve traffic from 20 users fine. Assuming some other part doesn't fall down first.

Re:Why Wasn't Ruby 3 Faster? by jiofih on Thursday February 11, 2021 @04:58AM (#26099878)
The first enterprise Java app I was a part of, failed out of the gate because some external requests were too long and exhausted the thread pool (100 by default).
Re:Why Wasn't Ruby 3 Faster? by Person5478 on Thursday February 11, 2021 @08:28AM (#26101241)
yeah, Heroku infamously had a really hard time getting Ruby to scale well.

Ruby traded safety (GIL) for absolutely speed, although it should be noted that Ruby's C interfaces do allow you to op out of the GIL, which means if speed is absolutely paramount you can write a Ruby C extension to opt out of it.

I've done it in the past, but OTOH if you're to that point maybe Ruby no longer makes sense.

Re:Why Wasn't Ruby 3 Faster? by ioquatix on Wednesday February 10, 2021 @09:08PM (#26097428)
This problem is being addressed in Ruby 3.
Re:Why Wasn't Ruby 3 Faster? by cutler on Wednesday February 10, 2021 @10:40PM (#26098015)
Ruby 3 seems to be going the way of Perl 6, ie. always about to be more efficient/faster sometime in the future. I hope not but isn't there a limit to how much you can re-jig an interpreted language designed in the early 90s? The same applies to Python.
Re:Why Wasn't Ruby 3 Faster? by dragonwriter on Thursday February 11, 2021 @03:42AM (#26099511)
> Ruby 3 seems to be going the way of Perl 6, ie. always about to be more efficient/faster sometime in the future.

“Perl 6” hasn’t been a thing for more than a year.

As for Ruby 3, the concurrency improvements are here today. The Actor-model parallelism of Ractors is here, if experimental, today. JIT improvements are here today.

Yes, there's also more stuff on the horizon building on that, but it is simply not the case that efficiencies from Ruby 3 are so e kind of continuously receding mirage.

Re:Why Wasn't Ruby 3 Faster? by lizmat on Monday February 15, 2021 @10:06AM (#26143374)
To be clear: "Perl 6" has been renamed to the Raku Programming Language (https://raku.org using the #rakulang tag on social media) and is very much a thing :-)
Re:Why Wasn't Ruby 3 Faster? by bdcravens on Thursday February 11, 2021 @12:18AM (#26098491)
The same also applies to Javascript.
Re:Why Wasn't Ruby 3 Faster? by petre on Thursday February 11, 2021 @12:41AM (#26098607)
Yup, only the Node runtime is very fast, pretty much 2x-3x times faster than Python 3.6 and Perl 5.26 and 4-5x faster than Ruby 2.4 for non I/O operations (loop, push to array, set hash keys). Only Lua and Luajit beats it. Raku/Perl6 was still slower than Ruby last time I checked. My tests were crunching primes and the Raku foreach loop had worse performance than the loop statement (ugly C-style loop). For number crunching Raku is slower probably because of the rational math.

Anyway, I like Ruby more than any of those languages, so hopefully speed in 3.0 is at least on par with Python and Perl now.

Re:Why Wasn't Ruby 3 Faster? by bdcravens on Thursday February 11, 2021 @01:33AM (#26098867)
Now Ruby just needs someone putting Google-level resources into optimizing the runtime (since most of Node's performance comes from v8)
Re:Why Wasn't Ruby 3 Faster? by SahAssar on Saturday February 13, 2021 @08:24PM (#26128818)
I don't think anyone put google-level cash into LuaJIT but it still manages to be pretty fast.