Just-in-Time Compiling Ruby Regexps on TruffleRuby
summary
TruffleRuby uses Truffle Regex to just-in-time compile Ruby regexps to machine code via GraalVM, replacing backtracking engines like onigmo/joni with finite-state machines and per-state inlined loop bodies. Microbenchmarks show up to 40× faster and larger workloads 2.3–9× speedups; unsupported features fall back to joni/backtracking and emit warnings. The implementation avoids REDoS by providing linear-time matching and unrolls counted quantifiers while tracking capture boundaries.
AI-written summary · about
chapters (20)
- 0:00Introduction
- 0:27TruffleRuby
- 0:53Background on regex engines
- 2:25What is TruffleRuby
- 3:50Regular Expressions
- 4:51TRegex
- 6:43Infinite Quantifiers
- 7:20Capture Groups
- 8:02Supported Features
- 9:47Unsupported Features
- 11:31The Loop
- 12:42State Machine
- 14:35Performance
- 14:58Micro benchmarks
- 16:32Larger benchmarks
- 17:49Liquid Powers
- 18:50Regular Expression Denial of Service
- 20:31Atomic Groups
- 22:17Conclusion
- 23:01Outro
related talks
30m(Re)make Regexp in Ruby: Democratizing internals for the JIT
30mFast Metaprogramming with Truffle
43mParallel and Thread-Safe Ruby at High-Speed with TruffleRuby
42mImproving TruffleRuby’s Startup Time with the SubstrateVM
44mImproving TruffleRuby’s Startup Time with the SubstrateVM
35mRuby’s C Extension Problem and How We're Solving It
38m"Parallel and Thread-Safe Ruby at High-Speed with TruffleRuby"
32mExperiments in sharing Java VM technology with CRuby
