summaryrefslogtreecommitdiff
path: root/include/ruby/ruby.h
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2026-01-18 10:33:54 +0100
committerJean Boussier <jean.boussier@gmail.com>2026-01-18 16:31:31 +0100
commit6cd4549060a608d8a7e5ee0dde2c4b69b08d7f6e (patch)
tree17cd606e1d3ecd918d00c515126f29b0b3456a3e /include/ruby/ruby.h
parentd1dc4bdb2fe7f16e6da78c0930353e4a5031465a (diff)
Optimize File.join common use case
`File.join` is a hotspot for common libraries such as Zeitwerk and Bootsnap. It has a fairly flexible signature, but 99% of the time it's called with just two (or a small number of) UTF-8 strings. If we optimistically optimize for that use case we can cut down a large number of type and encoding checks, significantly speeding up the method. The one remaining expensive check we could try to optimize is `str_null_check`. Given it's common to use the same base string for joining, we could memoize it. Also we could precompute it for literal strings. ``` compare-ruby: ruby 4.1.0dev (2026-01-17T14:40:03Z master 00a3b71eaf) +PRISM [arm64-darwin25] built-ruby: ruby 4.1.0dev (2026-01-18T12:10:38Z spedup-file-join 069bab58d4) +PRISM [arm64-darwin25] warming up.... | |compare-ruby|built-ruby| |:-------------|-----------:|---------:| |two_strings | 2.475M| 9.444M| | | -| 3.82x| |many_strings | 551.975k| 2.346M| | | -| 4.25x| |array | 514.946k| 522.034k| | | -| 1.01x| |mixed | 621.236k| 633.189k| | | -| 1.02x| ```
Diffstat (limited to 'include/ruby/ruby.h')
0 files changed, 0 insertions, 0 deletions