by Thomas Leitner
(?~exp) (also in 2.4.1)-"literal" (String#-@) optimized to return the same object (same as "literal".freeze in Ruby 2.1+) Feature #13295binding.irb automatically requires irb and runs Bug #13099trace instructions (dynamic instrumentation is used instead) Feature #14104def foo(&b); bar(&b); end) is about 3 times faster than Ruby 2.4 by “Lazy Proc allocation” technique. Feature #14045Array#concat, Enumerable#sort_by, String#concat, String#index, Time#+, and more.IO.copy_stream uses copy_file_range(2) to provide copy offloading. Feature #13867Note: The items for the slides “New Features” and “Performance Improvements” were mostly taken verbatim from the first two links.
--jit to activate it (there are some other options)Demo time
ruby -ve "puts RubyVM::InstructionSequence.
compile('x, y = 1, 2; [x, y].max').disasm"
benchmarkbenchmark-ipsbenchmark-driverUsage:
Benchmark.bm do |x|
x.report("name1") { code1 }
x.report("name2") { code2 }
end
Benchmark.bmbm since it warms up the runtimeUsage like with benchmark:
Benchmark.ips do |x|
x.report("name1") { code1 }
x.report("name2", "code-as-string")
x.compare!
end
Usage similar:
Benchmark.driver do |x|
x.prelude "set-up code here"
x.report("name1", "code-as-string")
x.report("name2", "code-as-string")
end
a < b ? b : a
vs
[a, b].max


The official benchmark for verifying the Ruby 3x3 goal!
git clone git@github.com:mame/optcarrot.git
cd optcarrot
# switch to Ruby 2.6-preview2
ruby -Ilib bin/optcarrot --benchmark examples/Lan_Master.nes
ruby --jit -Ilib bin/optcarrot --benchmark examples/Lan_Master.nes
# switch to TruffleRuby :)
ruby -Ilib -r./tools/shim bin/optcarrot --benchmark examples/Lan_Master.nes
You can find the files used during the presentation in the files directory.