Project

General

Profile

Actions

Feature #19287

open

Let DelegateClass respect the original method's arity in case of 0

Added by matsuda (Akira Matsuda) almost 2 years ago. Updated about 1 year ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:111523]

Description

As reported in #19165, method delegation with *, **, and ... adds some overhead for a method that takes no argument. And current implementation of delegations in forwardable and delegate basically define all methods to take splat parameters.

But, with regard to DelegateClass, we can investigate the arity of the target methods in the initializer, then we can define the delegation method not to take the splat for zero arity methods.

A benchmark on trunk today results in 37% runtime performance improvement on a such method.

Benchmark:
Warming up --------------------------------------
old 551.697k i/100ms
new 721.906k i/100ms
Calculating -------------------------------------
old 6.511M (± 0.8%) i/s - 33.102M in 5.084530s
new 8.925M (± 1.0%) i/s - 44.758M in 5.015619s

Comparison:
new: 8924652.2 i/s
old: 6510691.1 i/s - 1.37x (± 0.00) slower

Patch: https://github.com/ruby/ruby/pull/7045

Actions

Also available in: Atom PDF

Like0
Like0Like0