Skip to content

Reduce overhead of kwargs for no-arg methods and blocks#8021

Merged
enebo merged 4 commits intojruby:masterfrom
enebo:less_kws_instrs
Nov 24, 2023
Merged

Reduce overhead of kwargs for no-arg methods and blocks#8021
enebo merged 4 commits intojruby:masterfrom
enebo:less_kws_instrs

Conversation

@enebo
Copy link
Member

@enebo enebo commented Nov 23, 2023

There is some improvement with JIT and indy but my larger goal is to speed up startup time and removing recv_keywords and short-circuiting to a simple check_arity instr has a big effect on tiny no-arg methods/blocks.

BEFORE:

jruby --dev ../snippets/bench1.rb
Warming up --------------------------------------
                foo2   425.349k i/100ms
                 foo   439.825k i/100ms
Calculating -------------------------------------
                foo2      4.697M (± 1.1%) i/s -     94.002M in  20.015869s
                 foo      4.887M (± 0.9%) i/s -     98.081M in  20.071418s

Comparison:
                 foo:  4887008.2 i/s
                foo2:  4697008.2 i/s - 1.04x  slower

AFTER:

jruby --dev ../snippets/bench1.rb
Warming up --------------------------------------
                foo2   427.370k i/100ms
                 foo   599.189k i/100ms
Calculating -------------------------------------
                foo2      4.771M (± 0.9%) i/s -     95.731M in  20.065909s
                 foo      7.012M (± 1.3%) i/s -    140.210M in  19.999977s

Comparison:
                 foo:  7011664.4 i/s
                 foo2:  4771233.1 i/s - 1.47x  slower
require 'benchmark/ips'

def foo
  1
end

def foo2(a)
  1
end

Benchmark.ips do |x|
  x.config(:time => 20, :warmup => 20)


  x.report("foo2", "foo2(1)")
  x.report("foo", "foo")

  x.compare!
end

@enebo enebo added this to the JRuby 9.4.6.0 milestone Nov 23, 2023
@enebo enebo merged commit ad41813 into jruby:master Nov 24, 2023
@enebo enebo deleted the less_kws_instrs branch November 24, 2023 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant