4 ms·
It's been fast for a while now.
by doppp 2y ago
It's been fast for a while now.
- Thaxll 2y agoEven a 50% or 2x speed improvment still make it a pretty slow language. It's in the Python range.
- CyberDildonics 2y agoWhat is fast here? Ruby has usually been about 1/150th the speed of C.
- kenhwang 2y agoIf the code JITs well, Ruby performs somewhere between Go and NodeJS. Without the JIT, it's similar to Lua.
- CyberDildonics 2y agoIf the code JITs well What does this mean? Any JIT can make a tight loop of math and arrays run well but that doesn't mean a typical program runs well.
- kenhwang 2y agoFor Ruby, it's code where variables and method input/return types can be inferred to remain static, and variable scope/lifetime is finite. From my understanding, much of the performance gain was from removing the need for a lot of type checking and dynamic lookup/dispatch when types were unknown. So basically, writing code similarly to a statically typed compiled language.
- neonsunset 2y agoNode uses V8 which has a very advanced JIT compiler for the hot code, which does a lot of optimizations for reducing the impact of JS's highly dynamic type system. The claim that Ruby YJIT beats this is not supported by the data to put it mildly: https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/node-ruby.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/... (scroll down on each submission and you will see it uses YJIT) (and Go is not a paragon of absolute performance either)
- kenhwang 2y agoNot at all saying Ruby's compiler is more capable, more that typical Ruby code is easier to optimize by their JIT design than typical JS, largely because Ruby's type system is more sane. The whitepapers that inspired Ruby's JIT was first tested against a saner subset of JS, and shown to have some promising performance improvement. The better language/JIT compatibility is why the current Ruby JIT is actually showing performance improvements over the previous more traditionally designed JIT attempts. JS can get insanely fast when it's written like low level code that can take advantage of its much more advanced compiling abilities; like when it's used as a WASM target with machine generated code. But humans tend to not write JS that way. Agreed about Go as well, it tends to be on the slow side for compiled languages. I called it out not as an example of a fast language, but because it's typical performance is well known and approximately where the upper bound of how fast Ruby can get.
- plagiarist 2y agoI did a quick search for the white papers and couldn't find them. Would you be kind enough to leave a link or a title? It sounds interesting, I'd like to read more.
- kenhwang 2y agoI believe this is the paper that started it all (there are a couple of follow up papers): https://arxiv.org/pdf/1411.0352v1 https://arxiv.org/pdf/1411.0352v1 The author was eventually hired to develop YJIT.
- schneems 2y agoTo add some nuance to the word "fast." When we optimize Ruby for performance we debate how to eliminate X thousand heap allocations. When people in Rust optimize for performance, they're talking about how to hint to the compiler that the loop would benefit from SIMD. Two different communities, two wildly different bars for "fast." Ruby is plenty performant. I had a python developer tell me they were excited for the JIT work in Ruby as they hoped that Python could adopt something similar. For us the one to beat (or come closer to) would be Node.js. We are still slower then them (lots of browser companies spent a LOT of time optimizing javascript JIT), but I feel for the relative size of the communities Ruby is able to punch above its weight. I also feel that we should be celebrating tides that raise all ships. Not everything can (or should be) written in C. I personally celebrate any language getting faster, especially when the people doing it share as widely and are as good of a communicator as Aaron.
- nicoburns 2y agoHas it? I thought Ruby was pretty much the benchmark for the slowest language. What is it faster than?
- pansa2 2y agoPython. At least, it was a few years ago. Both languages have added JIT compilers since then, so I’m not sure how the most recent versions compare.
- chefandy 2y agoI see some people say this but I’ve never seen a benchmark support that if you include performance-focused distributions like pypy. https://programming-language-benchmarks.vercel.app/amp/python-vs-ruby https://programming-language-benchmarks.vercel.app/amp/pytho... Is there somewhere with benchmarks that supports the idea that Ruby is faster than Python?
- pansa2 2y agoFair point, I was specifically referring to the CPython interpreter. I don’t know if there’s a benchmark that compares PyPy to JIT-compiled Ruby.
- chefandy 2y agoLooks the the one at that link does unless there's some newer versioning thing I'm not aware of. The top results seem to be comparing pypy 3.10.14 and ruby/yjit 3.4.1.
- pjmlp 2y agoBecause unfortunately PyPy is largely ignored by the community , despite their heroic efforts.
- deleted 2y ago[deleted]