Improvement of REXML and speed up using StringScanner
summary
REXML gets concrete speedups by replacing regex-heavy parsing with Ruby's StringScanner and byte-level reads: benchmarks show REXML 3.4.1 = up to 60% faster compared to 3.2.6, YJIT adds further gains, and microbenchmarks show StringScanner gives 1.8x to 3.6x speedups (55% faster for scan-regex vs regex check; scanUntil up to ~3.6x on long CDATA). Changes also reduce temporary string allocations by using peek_byte and match-based checks, and the improved parser is stable in benchmarks.
AI-written summary · about
chapters (8)
- 0:00Introduction and background
- 5:03What is REXML and XML
- 9:04Motivation for speed improvement
- 10:11StringScanner basics
- 13:56Replacing regex with StringScanner
- 20:00Performance benefits of StringScanner
- 23:42Optimization techniques in Ruby 3.1.2
- 28:21Q&A and summary
related talks
28mMaking the RBS Parser Faster
39m"300x faster ruby"
30m(Re)make Regexp in Ruby: Democratizing internals for the JIT
24mJust-in-Time Compiling Ruby Regexps on TruffleRuby
44mConsuming Gherkin: One Byte at a Time
39mRegular Expressions Inside Out
32mParsing Ruby
33mRuby the Hard Way: Writing Bytecode to Optimize Plain Ruby
