1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/benchmark
Takashi Kokubun 151f8be40d
Make JIT-ed leave insn leaf
to eliminate sp / pc moves by cancelling JIT execution on interrupts.

$ benchmark-driver benchmark.yml -v --rbenv 'before --jit;after --jit' --repeat-count=12 --output=all
before --jit: ruby 2.8.0dev (2020-04-01T03:48:56Z master 5a81562dfe) +JIT [x86_64-linux]
after --jit: ruby 2.8.0dev (2020-04-01T04:58:01Z master 39beb26a27) +JIT [x86_64-linux]
Calculating -------------------------------------
                                 before --jit           after --jit
Optcarrot Lan_Master.nes    75.06409603894944     76.06422026555558 fps
                            75.12025067279242     78.48161731616810
                            77.42020273492177     79.78958240950033
                            79.07253675128945     79.88645902325614
                            79.99179109732327     80.33743931749331
                            80.07633091008627     80.53790081529166
                            80.15450942667547     80.99048270668010
                            80.48372803283709     81.70497146081003
                            80.57410149187352     82.79494539467382
                            81.80449157081202     82.85797792223954
                            82.24629397834902     83.00603891515506
                            82.63708148686703     83.23221006969828

$ benchmark-driver -v --rbenv 'before;before --jit;after --jit' benchmark/mjit_leave.yml --repeat-count=4
before: ruby 2.8.0dev (2020-04-01T03:48:56Z master 5a81562dfe) [x86_64-linux]
before --jit: ruby 2.8.0dev (2020-04-01T03:48:56Z master 5a81562dfe) +JIT [x86_64-linux]
after --jit: ruby 2.8.0dev (2020-04-01T04:58:01Z master 39beb26a27) +JIT [x86_64-linux]
Calculating -------------------------------------
                         before  before --jit  after --jit
          mjit_leave   106.656M       82.786M      91.635M i/s -    200.000M times in 1.875183s 2.415881s 2.182569s

Comparison:
                       mjit_leave
              before: 106656239.9 i/s
         after --jit:  91635143.7 i/s - 1.16x  slower
        before --jit:  82785537.2 i/s - 1.29x  slower
2020-03-31 22:10:16 -07:00
..
gc don't use GC::Profiler on default. 2018-09-28 05:28:12 +00:00
lib Remove unneeded exec bits from some files 2019-11-09 21:36:30 +09:00
other-lang n+1 to include n in range 2019-08-05 09:04:32 +09:00
app_answer.rb
app_aobench.rb benchmark/app_aobench.rb: complete commented code to write the image to a file 2019-01-21 12:31:29 +00:00
app_erb.yml benchmark/app_erb.yml: remove unused variable 2018-12-22 01:43:45 +00:00
app_factorial.rb
app_fib.rb
app_lc_fizzbuzz.rb
app_mandelbrot.rb
app_pentomino.rb
app_raise.rb
app_strconcat.rb
app_tak.rb
app_tarai.rb
app_uri.rb
array_flatten.yml Optimize Array#flatten and flatten! for already flattened arrays (#2495) 2019-09-28 01:24:24 +09:00
array_intersection.yml Benchmark for [Feature #16155] 2019-10-22 22:49:48 +09:00
array_sample_100k_10.rb
array_sample_100k_11.rb
array_sample_100k__1k.rb
array_sample_100k__6k.rb
array_sample_100k__100.rb
array_sample_100k___10k.rb
array_sample_100k___50k.rb
array_shift.rb
array_small_and.rb
array_small_diff.rb
array_small_or.rb
array_sort_block.rb
array_sort_float.rb
array_values_at_int.rb
array_values_at_range.rb
bighash.rb
cgi_escape_html.yml Optimize CGI.escapeHTML by reducing buffer extension 2019-06-05 21:07:04 +09:00
complex_float_add.yml benchmark/complex_float_*.yml: New benchmarks 2019-01-01 12:20:04 +00:00
complex_float_div.yml benchmark/complex_float_*.yml: New benchmarks 2019-01-01 12:20:04 +00:00
complex_float_mul.yml benchmark/complex_float_*.yml: New benchmarks 2019-01-01 12:20:04 +00:00
complex_float_new.yml benchmark/complex_float_*.yml: New benchmarks 2019-01-01 12:20:04 +00:00
complex_float_power.yml benchmark/complex_float_*.yml: New benchmarks 2019-01-01 12:20:04 +00:00
complex_float_sub.yml benchmark/complex_float_*.yml: New benchmarks 2019-01-01 12:20:04 +00:00
dir_empty_p.rb
enum_lazy_grep_v_20.rb
enum_lazy_grep_v_50.rb
enum_lazy_grep_v_100.rb
enum_lazy_uniq_20.rb
enum_lazy_uniq_50.rb
enum_lazy_uniq_100.rb
erb_render.yml
fiber_chain.yml Drop executable bit of *.{yml,h,mk.tmpl} 2020-01-22 16:04:38 +09:00
fiber_locals.yml Let execution context local storage be an ID table 2020-01-11 14:40:36 +13:00
file_chmod.rb
file_rename.rb
hash_aref_dsym.rb
hash_aref_dsym_long.rb
hash_aref_fix.rb
hash_aref_flo.rb
hash_aref_miss.rb
hash_aref_str.rb
hash_aref_sym.rb
hash_aref_sym_long.rb
hash_defaults.yml Speeds up fallback to Hash#default_proc in rb_hash_aref by removing a method call 2020-01-08 18:09:52 +09:00
hash_dup.yml Stop making a redundant hash copy in Hash#dup (#2489) 2019-10-21 17:29:21 +09:00
hash_flatten.rb
hash_ident_flo.rb
hash_ident_num.rb
hash_ident_obj.rb
hash_ident_str.rb
hash_ident_sym.rb
hash_keys.rb
hash_literal_small2.rb Add benchmark for hash small literals 2018-12-06 18:20:11 +00:00
hash_literal_small4.rb Add benchmark for hash small literals 2018-12-06 18:20:11 +00:00
hash_literal_small8.rb Add benchmark for hash small literals 2018-12-06 18:20:11 +00:00
hash_long.rb
hash_shift.rb
hash_shift_u16.rb
hash_shift_u24.rb
hash_shift_u32.rb
hash_small2.rb
hash_small4.rb
hash_small8.rb
hash_to_proc.rb
hash_values.rb
int_quo.rb
io_copy_stream_write.rb
io_copy_stream_write_socket.rb
io_file_create.rb
io_file_read.rb
io_file_write.rb
io_nonblock_noex.rb
io_nonblock_noex2.rb
io_pipe_rw.rb
io_select.rb
io_select2.rb
io_select3.rb
irb_color.yml Add a benchmark using IRB::Color 2019-06-01 20:07:50 +09:00
irb_exec.yml Make sure to suppress .irbrc on benchmark 2019-06-10 22:04:52 +09:00
kernel_clone.yml support builtin for Kernel#clone 2020-03-17 19:37:07 +09:00
keyword_arguments.yml Reduce allocations for keyword argument hashes 2020-03-17 12:09:43 -07:00
loop_for.rb
loop_generator.rb
loop_times.rb
loop_whileloop.rb
loop_whileloop2.rb
marshal_dump_flo.rb
marshal_dump_load_geniv.rb
marshal_dump_load_time.rb
match_gt4.rb Reduce ONIG_NREGION from 10 to 4: power of 2 and testing revealed most pattern matches are less than or equal to 4 results 2019-05-07 21:58:55 +09:00
match_small.rb Reduce ONIG_NREGION from 10 to 4: power of 2 and testing revealed most pattern matches are less than or equal to 4 results 2019-05-07 21:58:55 +09:00
mjit_exec_jt2jt.yml Reduce ISeq size of mjit_exec benchmark 2019-09-26 22:13:31 +09:00
mjit_exec_vm2jt.yml Reduce ISeq size of mjit_exec benchmark 2019-09-26 22:13:31 +09:00
mjit_exec_vm2vm.yml Reduce ISeq size of mjit_exec benchmark 2019-09-26 22:13:31 +09:00
mjit_exivar.yml Remove an unused pragma 2020-03-30 23:30:08 -07:00
mjit_leave.yml Make JIT-ed leave insn leaf 2020-03-31 22:10:16 -07:00
nil_p.yml Revert "Revert "Add a specialized instruction for .nil? calls"" 2019-08-02 23:25:38 +09:00
range_last.yml benchmark/range_last.yml: remove needless prelude 2019-01-06 15:46:21 +00:00
README.md
realpath.yml Use realpath(3) instead of custom realpath implementation if available 2019-07-01 11:46:30 -07:00
require.yml Close created files [ci skip] 2019-08-10 11:26:23 +09:00
require_thread.yml Close created files [ci skip] 2019-08-10 11:26:23 +09:00
securerandom.rb
so_ackermann.rb delete emacs mode lines [ci skip] 2018-12-27 06:12:09 +00:00
so_array.rb delete emacs mode lines [ci skip] 2018-12-27 06:12:09 +00:00
so_binary_trees.rb
so_concatenate.rb delete emacs mode lines [ci skip] 2018-12-27 06:12:09 +00:00
so_count_words.yml delete emacs mode lines [ci skip] 2018-12-27 06:12:09 +00:00
so_exception.rb delete emacs mode lines [ci skip] 2018-12-27 06:12:09 +00:00
so_fannkuch.rb
so_fasta.rb
so_k_nucleotide.yml
so_lists.rb
so_mandelbrot.rb
so_matrix.rb delete emacs mode lines [ci skip] 2018-12-27 06:12:09 +00:00
so_meteor_contest.rb
so_nbody.rb
so_nested_loop.rb delete emacs mode lines [ci skip] 2018-12-27 06:12:09 +00:00
so_nsieve.rb
so_nsieve_bits.rb
so_object.rb delete emacs mode lines [ci skip] 2018-12-27 06:12:09 +00:00
so_partial_sums.rb
so_pidigits.rb
so_random.rb
so_reverse_complement.yml
so_sieve.rb
so_spectralnorm.rb
string_capitalize.yml Improve performance of case-conversion methods 2019-05-03 23:59:18 +09:00
string_casecmp.yml Added more benchmarks for String 2020-02-29 15:42:24 +09:00
string_casecmp_p.yml Added more benchmarks for String 2020-02-29 15:42:24 +09:00
string_downcase.yml Added more benchmarks for String 2020-02-29 15:42:24 +09:00
string_index.rb
string_scan_re.rb
string_scan_str.rb
string_slice.yml Improve String#slice! performance 2020-01-31 17:12:05 +09:00
string_split.yml string.c: improve splitting into chars 2019-04-17 05:34:46 +00:00
string_swapcase.yml Added more benchmarks for String 2020-02-29 15:42:24 +09:00
string_upcase.yml Added more benchmarks for String 2020-02-29 15:42:24 +09:00
time_strptime.yml Time.strptime benchmarks 2019-01-07 02:05:21 +00:00
time_subsec.rb
vm1_attr_ivar.yml
vm1_attr_ivar_set.yml
vm1_block.yml
vm1_blockparam.yml
vm1_blockparam_call.yml
vm1_blockparam_pass.yml
vm1_blockparam_yield.yml
vm1_const.yml
vm1_ensure.yml
vm1_float_simple.yml
vm1_gc_short_lived.yml
vm1_gc_short_with_complex_long.yml
vm1_gc_short_with_long.yml
vm1_gc_short_with_symbol.yml
vm1_gc_wb_ary.yml
vm1_gc_wb_ary_promoted.yml
vm1_gc_wb_obj.yml
vm1_gc_wb_obj_promoted.yml
vm1_ivar.yml
vm1_ivar_set.yml
vm1_length.yml
vm1_lvar_init.yml
vm1_lvar_set.yml
vm1_neq.yml
vm1_not.yml
vm1_rescue.yml
vm1_simplereturn.yml
vm1_swap.yml
vm1_yield.yml
vm2_array.yml
vm2_bigarray.yml
vm2_bighash.yml
vm2_case.yml
vm2_case_lit.yml
vm2_defined_method.yml
vm2_dstr.yml
vm2_eval.yml
vm2_fiber_allocate.yml Improved fiber benchmarks. Increase number of iterations. 2019-07-12 11:56:51 +12:00
vm2_fiber_count.yml Add note about setting vm.max_map_count for Linux. 2019-07-18 20:54:55 +12:00
vm2_fiber_reuse.yml * remove trailing spaces. 2019-07-12 17:57:28 +09:00
vm2_fiber_reuse_gc.yml Add benchmark to help diagnose performance regression. 2019-07-18 11:13:49 +12:00
vm2_fiber_switch.yml Improved fiber benchmarks. Increase number of iterations. 2019-07-12 11:56:51 +12:00
vm2_freezestring.yml
vm2_method.yml
vm2_method_missing.yml
vm2_method_with_block.yml
vm2_module_ann_const_set.yml
vm2_module_const_set.yml
vm2_mutex.yml
vm2_newlambda.yml
vm2_poly_method.yml
vm2_poly_method_ov.yml
vm2_poly_same_method.yml reuse cc->call 2019-09-19 15:18:10 +09:00
vm2_poly_singleton.yml
vm2_proc.yml
vm2_raise1.yml
vm2_raise2.yml
vm2_regexp.yml Add a benchmark for opt_regexpmatch2 2019-09-02 13:46:33 +09:00
vm2_send.yml
vm2_string_literal.yml
vm2_struct_big_aref_hi.yml
vm2_struct_big_aref_lo.yml
vm2_struct_big_aset.yml
vm2_struct_big_href_hi.yml
vm2_struct_big_href_lo.yml
vm2_struct_big_hset.yml
vm2_struct_small_aref.yml
vm2_struct_small_aset.yml
vm2_struct_small_href.yml
vm2_struct_small_hset.yml
vm2_super.yml
vm2_unif1.yml
vm2_zsuper.yml
vm3_backtrace.rb
vm3_clearmethodcache.rb
vm3_gc.rb
vm3_gc_old_full.rb
vm3_gc_old_immediate.rb
vm3_gc_old_lazy.rb
vm_symbol_block_pass.rb
vm_thread_alive_check.yml Improve benchmarks and tests for threads. 2019-06-19 20:39:10 +12:00
vm_thread_close.rb
vm_thread_condvar1.rb
vm_thread_condvar2.rb
vm_thread_create_join.rb
vm_thread_mutex1.rb
vm_thread_mutex2.rb
vm_thread_mutex3.rb
vm_thread_pass.rb Fix typo in comment [ci skip] 2019-08-10 09:35:28 +09:00
vm_thread_pass_flood.rb Improve benchmarks and tests for threads. 2019-06-19 20:39:10 +12:00
vm_thread_pipe.rb
vm_thread_queue.rb Improve benchmarks and tests for threads. 2019-06-19 20:39:10 +12:00
vm_thread_sized_queue.rb
vm_thread_sized_queue2.rb
vm_thread_sized_queue3.rb
vm_thread_sized_queue4.rb
vm_thread_sleep.yml Improve benchmarks and tests for threads. 2019-06-19 20:39:10 +12:00

ruby/benchmark

This directory has benchmark definitions to be run with benchmark_driver.gem.

Normal usage

Execute gem install benchmark_driver and run a command like:

# Run a benchmark script with the ruby in the $PATH
benchmark-driver benchmark/app_fib.rb

# Run benchmark scripts with multiple Ruby executables or options
benchmark-driver benchmark/*.rb -e /path/to/ruby -e '/path/to/ruby --jit'

# Or compare Ruby versions managed by rbenv
benchmark-driver benchmark/*.rb --rbenv '2.5.1;2.6.0-preview2 --jit'

# You can collect many metrics in many ways
benchmark-driver benchmark/*.rb --runner memory --output markdown

# Some are defined with YAML for complex setup or accurate measurement
benchmark-driver benchmark/*.yml

See also:

Usage: benchmark-driver [options] RUBY|YAML...
    -r, --runner TYPE                Specify runner type: ips, time, memory, once (default: ips)
    -o, --output TYPE                Specify output type: compare, simple, markdown, record (default: compare)
    -e, --executables EXECS          Ruby executables (e1::path1 arg1; e2::path2 arg2;...)
        --rbenv VERSIONS             Ruby executables in rbenv (x.x.x arg1;y.y.y arg2;...)
        --repeat-count NUM           Try benchmark NUM times and use the fastest result or the worst memory usage
        --repeat-result TYPE         Yield "best", "average" or "worst" result with --repeat-count (default: best)
        --bundler                    Install and use gems specified in Gemfile
        --filter REGEXP              Filter out benchmarks with given regexp
        --run-duration SECONDS       Warmup estimates loop_count to run for this duration (default: 3)
    -v, --verbose                    Verbose mode. Multiple -v options increase visilibity (max: 2)

make benchmark

Using make benchmark, make update-benchmark-driver automatically downloads the supported version of benchmark_driver, and it runs benchmarks with the downloaded benchmark_driver.

# Run all benchmarks with the ruby in the $PATH and the built ruby
make benchmark

# Or compare with specific ruby binary
make benchmark COMPARE_RUBY="/path/to/ruby --jit"

# Run vm1 benchmarks
make benchmark ITEM=vm1

# Run some limited benchmarks in ITEM-matched files
make benchmark ITEM=vm1 OPTS=--filter=block

# You can specify the benchmark by an exact filename instead of using the default argument:
# ARGS = $$(find $(srcdir)/benchmark -maxdepth 1 -name '*$(ITEM)*.yml' -o -name '*$(ITEM)*.rb')
make benchmark ARGS=../benchmark/erb_render.yml

# You can specify any option via $OPTS
make benchmark OPTS="--help"

# With `make benchmark`, some special runner plugins are available:
#   -r peak, -r size, -r total, -r utime, -r stime, -r cutime, -r cstime
make benchmark ITEM=vm2_bigarray OPTS="-r peak"