
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
- Tweets321
- Following30
- Followers1.6K
- Likes256
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!
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…
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):
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
On larger Regexp-related benchmarks TruffleRuby+TRegex sees significant speedups from 2.3x to 9x faster than CRuby:
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!
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)/
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.










