Skip to content

Add send-with-block benchmark - #526

Merged
tekknolagi merged 2 commits into
mainfrom
mb-add-block-benchmark
Sep 17, 2026
Merged

tekknolagi merged 2 commits into
mainfrom
mb-add-block-benchmark

Conversation

@tekknolagi

@tekknolagi tekknolagi commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Benchmarks send-with-block, especially polymorphic send-with-block. Gives us information on how much inlining-driven monomorphization is helping.

@tekknolagi
tekknolagi marked this pull request as ready for review September 9, 2026 12:51
@tekknolagi
tekknolagi force-pushed the mb-add-block-benchmark branch from 63d3e63 to 4fc54ac Compare September 15, 2026 20:57
@tekknolagi
tekknolagi requested review from a team and k0kubun September 17, 2026 14:50
@tekknolagi tekknolagi added the jit label Sep 17, 2026
Comment thread benchmarks/block_methods.rb Outdated
Comment on lines +68 to +70
run_benchmark(1000) do
i = 0
while i < 10

@k0kubun k0kubun Sep 17, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How long does each iteration take? My understanding is that the shorter each iteration is, the noisier the benchmark is, because it needs to go through non-benchmark code a lot (after each iteration). So if it takes 1000 iterations to run for the default benchmark duration, I would make < 10 larger.

However, if the intention is to encourage a JIT to inline everything from the block given to run_benchmark and avoid staying in iterations that do not compile the block too long, I'm fine with configuring it this way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plum% ruby benchmarks/block_methods.rb
ruby 4.1.0dev (2026-09-17T15:01:37Z mb-condbranch-chec.. c4ea80f56a) +PRISM [arm64-darwin25]
itr:   time
 #1:  359ms
 #2:  361ms
 #3:  369ms
 #4:  361ms
 #5:  365ms
 #6:  360ms
 #7:  363ms
^Cbenchmarks/block_methods.rb:44:in 'block in Object#kernel_tap': Interrupt
        from benchmarks/block_methods.rb:42:in 'Kernel#tap'
        from benchmarks/block_methods.rb:42:in 'Object#kernel_tap'
        from benchmarks/block_methods.rb:75:in 'block in <main>'
        from /Users/emacs/Documents/code/yjit-bench/harness/harness.rb:30:in 'Object#realtime'
        from /Users/emacs/Documents/code/yjit-bench/harness/harness.rb:56:in 'Object#run_benchmark'
        from benchmarks/block_methods.rb:68:in '<main>'

plum% ruby --zjit benchmarks/block_methods.rb
ruby 4.1.0dev (2026-09-17T15:01:37Z mb-condbranch-chec.. c4ea80f56a) +ZJIT stats +PRISM [arm64-darwin25]
itr:   time
 #1:  267ms
 #2:  261ms
 #3:  222ms
 #4:   84ms
 #5:   85ms
 #6:   86ms
 #7:   86ms
 #8:   84ms
 #9:   85ms
#10:   84ms
#11:   83ms
#12:   84ms
#13:   85ms
#14:   84ms
#15:   83ms
#16:   95ms
#17:   91ms
^Cbenchmarks/block_methods.rb:15:in 'block in Object#array_map': Interrupt
        from benchmarks/block_methods.rb:13:in 'Array#map'
        from benchmarks/block_methods.rb:13:in 'Object#array_map'
        from benchmarks/block_methods.rb:72:in 'block in <main>'
        from /Users/emacs/Documents/code/yjit-bench/harness/harness.rb:30:in 'Object#realtime'
        from /Users/emacs/Documents/code/yjit-bench/harness/harness.rb:56:in 'Object#run_benchmark'
        from benchmarks/block_methods.rb:68:in '<main>'

plum%

@tekknolagi
tekknolagi enabled auto-merge (squash) September 17, 2026 20:16
@tekknolagi
tekknolagi merged commit 17dcac9 into main Sep 17, 2026
11 checks passed
@tekknolagi
tekknolagi deleted the mb-add-block-benchmark branch September 17, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants