A High-Performance Ruby Implementation on top of @GraalVM. See also https://xitter.cf/t.co/8zyzzTZynH and https://xitter.cf/t.co/bYkaWTz2ht

Joined January 2017
This is a small ray tracing benchmark in the CRuby repository (github.com/ruby/ruby/blob/ma…, from @aobench). CRuby 3.1 renders it in 38 seconds, TruffleRuby 22.2 in 3.8s, a nice 10x speedup!
1
5
24
Great work by Vesko Karaganev from @csmcr to optimize frequent byte mutations to TruffleRuby Strings. Here is a 7-min screencast: youtu.be/U4gbftHGwDU and the full report github.com/veselink1/truffle…
4
1
12
A simple & visual optimization: @brandonfish optimized Kernel#frozen? in TruffleRuby to fold to a constant, whether the object is frozen or not, by storing it in object Shape flags in github.com/oracle/trufflerub…. Compiler graphs for `obj.frozen?` before (2 reads) & after (1 read):
1
2
5
These performance improvements not only make Ruby apps faster they also improve security: ReDoS are not possible with TRegex because it always matches in linear time. TruffleRuby can warn for slow regexps which need backtracking and are not supported by TRegex
1
2
On larger Regexp-related benchmarks TruffleRuby+TRegex sees significant speedups from 2.3x to 9x faster than CRuby:
1
1
Here is TRegex on micro-benchmarks, it's 24 to 41 *times* faster than CRuby! It's so fast due to 3 reasons: * state machine instead of backtracking * JIT-compiled Regexps * the @GraalVM JIT inlines and optimizes Ruby code and Regexp code together!
1
7
17
TRegex just-in-time compiles those state machines to native code! The generated native code is near optimal and specific to a given regular expression. Here is the generated code illustrated as Ruby code for /a+(b|c)/
1
This approach to use a state machine or automaton for matching a Regexp has been known for a while (swtch.com/%7Ersc/regexp/rege…), but so far was never applied to Ruby Regexps. TRegex supports most Ruby Regexp features but not all.
1
1
An example state machine for /ab|ac/ looks like this:
1
TruffleRuby initially used a Regexp engine similar to what CRuby uses, which is a backtracking engine. Those engines are known to be slow and prone to ReDoS, so instead TruffleRuby uses now a new Regexp engine: TRegex, which uses state machines!
1
3