3 ms·
Some Ruby implementations are "riding on C". Others are not, e.g. Truffle Ruby. While beating C overall would be very hard because of the dynamism of Ruby, mos
by vidarh 3y ago
Some Ruby implementations are "riding on C". Others are not, e.g. Truffle Ruby.
While beating C overall would be very hard because of the dynamism of Ruby, most Ruby code is not very dynamic after a short warmup (loading for most code; connecting a database etc. for code using a dynamic ORM), and at least on specific code it's at least theoretically possible for a Ruby JIT to beat C by optimising to the actual runtime configuration and evaluate out all the dynamism that costs Ruby performance.
TruffleRuby goes part-way there, in terms of guarded section that makes assumptions about types but where the guards shunts code that breaks those assumptions onto a slow path, but a Ruby JIT or a combination of a bytecode compiler and JIT, can at least in theory go much further. E.g. a whole lot of the Ruby code library contains type checks that a compiler could hoist and/or elide.
Yjit is a baby step, but a good start.