15 ms·
To the extent it's about the GIL or lack thereof, I am confident that the amount of performance increase you would get by switching would be directly correlated
by jrochkind1 13y ago
To the extent it's about the GIL or lack thereof, I am confident that the amount of performance increase you would get by switching would be directly correlated with how much of your typical response generation time is spent waiting on I/O.
The _less_ time you spend waiting on I/O (you are cpu-bound), the _more_ performance increase you get from switching to an interpreter without a GIL.
Most of my web apps spend a very large percentage of their time waiting on I/O (chiefly an rdbms), but if you have a heavily optimized app that is more cpu-bound, you would see larger gains from a GIL-less interpreter.
This hypothesis just makes sense, and I also believe there's evidence for it in the benchmarking I did at: https://github.com/jrochkind/fake_work_app https://github.com/jrochkind/fake_work_app
- kbd 13y agoThanks for those benchmarks! You get a big boost by using multiple Puma workers on MRI. Under Rubinius you should be able to only use one Puma worker for max performance, right? I'd love to see benchmarks with Rubinius... ;)
- jrochkind1 13y agoAh, good point. Yeah, in theory, I think that's true, you could get away with only one worker on rubinius or jruby. I'm mostly sticking with MRI, so I mostly think about the other side -- on MRI you need multiple workers, yeah, but _even_ on MRI, you get a boost by using multi-threads _on each worker_. This is the thing lots of people are neglecting!
- jrochkind1 13y agoAlthough to the extent that there may be some shared resources between threads, which may be shared under an architecture where the more threads you have contending for resources, there is a performance penalty.... ...you _may_ seen performance improvements by having more than one worker even on jruby or rbx, without the GIL. It would really have to be benchmarked, with some apps with realistic profiles. But yeah, I'd expect the advantage of having more than one worker on rbx or jruby to be less. But it gets confusing. (The ActiveRecord database connection pool is the prime example of such a shared-under-contention resource)