-
-
Notifications
You must be signed in to change notification settings - Fork 939
Open
Description
Summary
Line-by-line string parsing (splitting and iterating over lines) is significantly slower in JRuby 10 compared to JRuby 1.7.
Benchmark
require 'benchmark'
text = ("Line of text number X\n" * 50_000)
n = 100
Benchmark.bm(20) do |x|
x.report("each_line") { n.times { text.each_line { |line| line } } }
x.report("lines.each") { n.times { text.lines.each { |line| line } } }
x.report("split(newline)") { n.times { text.split("\n").each { |line| line } } }
endResults
| Ruby | Time | Regression |
|---|---|---|
| MRI 3.4.7 | 0.034s | baseline |
| JRuby 1.7.27 | 0.019s | 0.6x (faster than MRI) |
| JRuby 10.0.2.0 | 0.069s | 3.6x slower than JRuby 1.7 |
JRuby 1.7 was faster than MRI for line parsing. JRuby 10 is now 2x slower than MRI and 3.6x slower than JRuby 1.7.
Impact
Affects applications doing:
- Log file processing
- CSV/text file parsing
- Any line-oriented I/O operations
Environment
- JRuby 10.0.2.0 on Java 21 (Temurin 21.0.9)
- JRuby 1.7.27 on Java 8 (Corretto 8.472)
- MRI 3.4.7
- macOS Darwin 25.1.0
Metadata
Metadata
Assignees
Labels
No labels