oracle / truffleruby

A high performance implementation of the Ruby programming language, built on GraalVM.
https://www.graalvm.org/ruby/
Other
2.98k stars 180 forks source link

Avoid excessive splitting of nodes caused by a unique proc being created per call when a method reference would suffice. #3529

Closed nirvdrum closed 2 months ago

nirvdrum commented 2 months ago

Truffle::Splitter.split will yield each split part if a block is provided or otherwise will collect the results into an array. These code paths were unified by creating a proc to Array#<<. This approach resulted in a new proc being allocated per call, which in turn created excessive splitting of Array#<< as reported in #3527. Since the method reference can be invoked directly, there's no need to turn it into a proc. This PR simplifies the code to eliminate that proc allocation.