ruby/benchmark
normal e52b3a0e2c hash.c (rb_num_hash_start): avoid pathological behavior
The OR-ing itself is bad for a hash function, and shifting 3 bits
left was not enough to undo the damage done by shifting
(RUBY_SPECIAL_SHIFT+3) bits right.  Experimentally, shifting 16-17
bits seemed to work well in preparing the number for murmur hash.

Add a few more benchmarks to based on bm_hash_shift to ensure
we don't hurt performance too much with tweaks.

I'm pretty confident about this change and commiting it now;
especially since we're still using Murmur behind it (but perhaps
we can update to a newer hash from Murmur...)

[ruby-core:72028] [Feature #11405]

target 0: a (ruby 2.3.0dev (2015-12-11 trunk 53027) [x86_64-linux]) at "/home/ew/rrrr/b/ruby"
target 1: b (ruby 2.3.0dev (2015-12-11 master 53027) [x86_64-linux]) at "/home/ew/ruby/b/ruby"

benchmark results:
minimum results in each 5 measurements.
Execution time (sec)
name	a	b
hash_aref_dsym	0.279	0.276
hash_aref_dsym_long	4.951	4.936
hash_aref_fix	0.281	0.283
hash_aref_flo	0.060	0.060
hash_aref_miss	0.409	0.410
hash_aref_str	0.387	0.385
hash_aref_sym	0.275	0.270
hash_aref_sym_long	0.410	0.411
hash_flatten	0.252	0.237
hash_ident_flo	0.035	0.032
hash_ident_num	0.254	0.251
hash_ident_obj	0.252	0.256
hash_ident_str	0.250	0.252
hash_ident_sym	0.259	0.270
hash_keys	0.267	0.267
hash_shift	0.016	0.015
hash_shift_u16	0.074	0.072
hash_shift_u24	0.071	0.071
hash_shift_u32	0.073	0.072
hash_to_proc	0.008	0.008
hash_values	0.263	0.264

Speedup ratio: compare with the result of `a' (greater is better)
name	b
hash_aref_dsym	1.009
hash_aref_dsym_long	1.003
hash_aref_fix	0.993
hash_aref_flo	1.001
hash_aref_miss	0.996
hash_aref_str	1.006
hash_aref_sym	1.017
hash_aref_sym_long	0.998
hash_flatten	1.061
hash_ident_flo	1.072
hash_ident_num	1.012
hash_ident_obj	0.987
hash_ident_str	0.993
hash_ident_sym	0.959
hash_keys	0.997
hash_shift	1.036
hash_shift_u16	1.039
hash_shift_u24	1.001
hash_shift_u32	1.017
hash_to_proc	1.001
hash_values	0.995

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-11 08:23:46 +00:00
..
gc * benchmark/gc/gcbench.rb: check GC::OPTS availability 2013-12-19 01:49:59 +00:00
other-lang * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_app_answer.rb * benchmark/bm_app_answer.rb: revert r42990, benchmark scripts should 2013-09-22 10:01:22 +00:00
bm_app_aobench.rb bm_app_aobench.rb: update links [ci skip] 2014-09-16 10:18:53 +00:00
bm_app_erb.rb * benchmark/bm_app_erb.rb: increase loop count. too short 2011-07-01 10:39:12 +00:00
bm_app_factorial.rb * benchmark/bm_app_erb.rb: increase loop count. too short 2011-07-01 10:39:12 +00:00
bm_app_fib.rb set svn:eol-style 2007-02-12 23:01:19 +00:00
bm_app_lc_fizzbuzz.rb * benchmark/bm_app_lc_fizzbuzz.rb: should skip output on benchmark. 2014-09-08 07:08:56 +00:00
bm_app_mandelbrot.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_app_pentomino.rb set svn:eol-style 2007-02-12 23:01:19 +00:00
bm_app_raise.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_app_strconcat.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_app_tak.rb set svn:eol-style 2007-02-12 23:01:19 +00:00
bm_app_tarai.rb set svn:eol-style 2007-02-12 23:01:19 +00:00
bm_app_uri.rb * set eol-style. 2007-11-16 01:30:29 +00:00
bm_array_shift.rb * array.c: Improve performance of Array#shift. use shared instead of 2015-01-03 02:27:50 +00:00
bm_hash_aref_dsym.rb new benchmarks for hashing dsyms and fixnums 2015-07-29 19:54:12 +00:00
bm_hash_aref_dsym_long.rb new benchmarks for hashing dsyms and fixnums 2015-07-29 19:54:12 +00:00
bm_hash_aref_fix.rb new benchmarks for hashing dsyms and fixnums 2015-07-29 19:54:12 +00:00
bm_hash_aref_flo.rb bm_hash_aref_flo.rb: fix data 2015-03-25 02:20:43 +00:00
bm_hash_aref_miss.rb st.c: use power-of-two sizes to avoid slow modulo ops 2014-03-22 23:34:21 +00:00
bm_hash_aref_str.rb st.c: use power-of-two sizes to avoid slow modulo ops 2014-03-22 23:34:21 +00:00
bm_hash_aref_sym.rb benchmark/bm_hash_aref_sym*.rb: force static symbols 2014-10-09 03:44:12 +00:00
bm_hash_aref_sym_long.rb benchmark/bm_hash_aref_sym*.rb: force static symbols 2014-10-09 03:44:12 +00:00
bm_hash_flatten.rb * benchmark/bm_hash_flatten.rb: added. r43896 is about 4 times faster 2013-11-28 10:50:41 +00:00
bm_hash_ident_flo.rb fix flonum hashing regression from r45384 2015-01-22 07:48:59 +00:00
bm_hash_ident_num.rb st.c: use power-of-two sizes to avoid slow modulo ops 2014-03-22 23:34:21 +00:00
bm_hash_ident_obj.rb st.c: use power-of-two sizes to avoid slow modulo ops 2014-03-22 23:34:21 +00:00
bm_hash_ident_str.rb st.c: use power-of-two sizes to avoid slow modulo ops 2014-03-22 23:34:21 +00:00
bm_hash_ident_sym.rb st.c: use power-of-two sizes to avoid slow modulo ops 2014-03-22 23:34:21 +00:00
bm_hash_keys.rb * benchmark/bm_hash_flatten.rb: added. r43896 is about 4 times faster 2013-11-28 10:50:41 +00:00
bm_hash_shift.rb * benchmark/bm_hash_shift.rb: add benchmark for Hash#shift 2013-04-25 05:03:30 +00:00
bm_hash_shift_u16.rb hash.c (rb_num_hash_start): avoid pathological behavior 2015-12-11 08:23:46 +00:00
bm_hash_shift_u24.rb hash.c (rb_num_hash_start): avoid pathological behavior 2015-12-11 08:23:46 +00:00
bm_hash_shift_u32.rb hash.c (rb_num_hash_start): avoid pathological behavior 2015-12-11 08:23:46 +00:00
bm_hash_to_proc.rb bm_hash_to_proc.rb 2015-11-10 09:22:37 +00:00
bm_hash_values.rb * benchmark/bm_hash_flatten.rb: added. r43896 is about 4 times faster 2013-11-28 10:50:41 +00:00
bm_io_file_create.rb * benchmark/bm_app_erb.rb: increase loop count. too short 2011-07-01 10:39:12 +00:00
bm_io_file_read.rb * benchmark/bm_app_erb.rb: increase loop count. too short 2011-07-01 10:39:12 +00:00
bm_io_file_write.rb * benchmark/bm_app_erb.rb: increase loop count. too short 2011-07-01 10:39:12 +00:00
bm_io_nonblock_noex.rb delay `exception: false' checks for minor speedup 2015-07-02 22:22:14 +00:00
bm_io_nonblock_noex2.rb io.c: avoid kwarg parsing in C API 2015-11-12 02:00:41 +00:00
bm_io_select.rb * benchmark/bm_io_select.rb, benchmark/bm_io_select2.rb: New. 2011-04-30 07:16:31 +00:00
bm_io_select2.rb * benchmark/bm_io_select[23].rb: use Process::RLIMIT_NOFILE only when 2011-11-17 11:24:07 +00:00
bm_io_select3.rb * benchmark/bm_io_select[23].rb: use Process::RLIMIT_NOFILE only when 2011-11-17 11:24:07 +00:00
bm_loop_for.rb properties. 2008-10-10 23:30:39 +00:00
bm_loop_generator.rb * thread.c: fix Mutex to be interruptable lock. 2007-08-27 16:48:14 +00:00
bm_loop_times.rb * parse.y: optimize 'for' statement when one variable given. 2008-10-10 19:19:36 +00:00
bm_loop_whileloop.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_loop_whileloop2.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_marshal_dump_flo.rb benchmark/bm_marshal_dump_flo.rb: new benchmark for [Bug #10761] 2015-01-23 08:13:59 +00:00
bm_marshal_dump_load_geniv.rb variable.c: avoid compatibility table with generic ivars 2015-05-30 00:20:15 +00:00
bm_marshal_dump_load_time.rb variable.c: avoid compatibility table with generic ivars 2015-05-30 00:20:15 +00:00
bm_require.rb * benchmark/bm_require.rb: new benchmark for require. 2015-10-08 21:31:49 +00:00
bm_require_thread.rb * benchmark/bm_require.rb: new benchmark for require. 2015-10-08 21:31:49 +00:00
bm_securerandom.rb * lib/securerandom.rb: use OpenSSL::BN for performance improvement. 2014-08-08 11:00:47 +00:00
bm_so_ackermann.rb set svn:eol-style 2007-02-12 23:01:19 +00:00
bm_so_array.rb set svn:eol-style 2007-02-12 23:01:19 +00:00
bm_so_binary_trees.rb * benchmark/bm_so_binary_trees.rb: disable `puts' method 2013-06-20 07:30:41 +00:00
bm_so_concatenate.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_so_count_words.rb * benchmark/driver.rb: added. 2007-09-27 06:46:31 +00:00
bm_so_exception.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_so_fannkuch.rb * benchmark/bm_app_erb.rb: increase loop count. too short 2011-07-01 10:39:12 +00:00
bm_so_fasta.rb * set eol-style. 2007-11-16 01:30:29 +00:00
bm_so_k_nucleotide.rb * set eol-style. 2007-11-16 01:30:29 +00:00
bm_so_lists.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_so_mandelbrot.rb * set eol-style. 2007-11-16 01:30:29 +00:00
bm_so_matrix.rb * benchmark/bm_app_erb.rb: increase loop count. too short 2011-07-01 10:39:12 +00:00
bm_so_meteor_contest.rb * benchmark/bm_so_meteor_contest.rb: fix a typo. 2015-04-20 03:45:35 +00:00
bm_so_nbody.rb * set eol-style. 2007-11-16 01:30:29 +00:00
bm_so_nested_loop.rb set svn:eol-style 2007-02-12 23:01:19 +00:00
bm_so_nsieve.rb * set eol-style. 2007-11-16 01:30:29 +00:00
bm_so_nsieve_bits.rb * benchmark/bm_so_nsieve_bits.rb: add an encoding pragma. 2012-11-21 07:15:03 +00:00
bm_so_object.rb set svn:eol-style 2007-02-12 23:01:19 +00:00
bm_so_partial_sums.rb * set eol-style. 2007-11-16 01:30:29 +00:00
bm_so_pidigits.rb * set eol-style. 2007-11-16 01:30:29 +00:00
bm_so_random.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_so_reverse_complement.rb * set eol-style. 2007-11-16 01:30:29 +00:00
bm_so_sieve.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_so_spectralnorm.rb * set eol-style. 2007-11-16 01:30:29 +00:00
bm_vm1_attr_ivar.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm1_attr_ivar_set.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm1_block.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm1_const.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm1_ensure.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm1_float_simple.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm1_gc_short_lived.rb * properties. 2013-11-06 00:21:05 +00:00
bm_vm1_gc_short_with_complex_long.rb * properties. 2013-11-06 00:21:05 +00:00
bm_vm1_gc_short_with_long.rb * properties. 2013-11-06 00:21:05 +00:00
bm_vm1_gc_short_with_symbol.rb * properties. 2013-11-06 00:21:05 +00:00
bm_vm1_gc_wb_ary.rb * benchmark/bm_vm1_gc_wb_ary.rb: run GC to finish "marking" phase. 2015-03-18 05:15:08 +00:00
bm_vm1_gc_wb_ary_promoted.rb * benchmark/bm_vm1_gc_wb_ary.rb: run GC to finish "marking" phase. 2015-03-18 05:15:08 +00:00
bm_vm1_gc_wb_obj.rb * benchmark/bm_vm1_gc_wb_ary.rb: run GC to finish "marking" phase. 2015-03-18 05:15:08 +00:00
bm_vm1_gc_wb_obj_promoted.rb * benchmark/bm_vm1_gc_wb_ary.rb: run GC to finish "marking" phase. 2015-03-18 05:15:08 +00:00
bm_vm1_ivar.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm1_ivar_set.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm1_length.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm1_lvar_init.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm1_lvar_set.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm1_neq.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm1_not.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm1_rescue.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm1_simplereturn.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm1_swap.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm1_yield.rb * benchmark/bm_vm1_yield.rb: add a benchmark to measure `yield' 2012-10-16 20:37:25 +00:00
bm_vm2_array.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm2_bigarray.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm2_bighash.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm2_case.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm2_case_lit.rb compile optimized case dispatch for nil/true/false 2015-12-08 01:46:45 +00:00
bm_vm2_defined_method.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm2_dstr.rb * benchmark/bm_vm2_dstr.rb: add a benchmark to measure 2012-10-16 23:47:51 +00:00
bm_vm2_eval.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm2_method.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm2_method_missing.rb * benchmark/bm_vm2_method_missing.rb: add a benchmark to measure 2012-10-17 07:26:58 +00:00
bm_vm2_method_with_block.rb * benchmark/bm_vm1_yield.rb: add a benchmark to measure `yield' 2012-10-16 20:37:25 +00:00
bm_vm2_mutex.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm2_newlambda.rb proc.c (rb_proc_alloc): inline and move to vm.c 2014-09-12 20:57:45 +00:00
bm_vm2_poly_method.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm2_poly_method_ov.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm2_proc.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm2_raise1.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm2_raise2.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm2_regexp.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm2_send.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm2_string_literal.rb string.c: fix non-embedded string 2015-10-07 11:43:17 +00:00
bm_vm2_struct_big_aref_hi.rb struct: avoid all O(n) behavior on access 2014-12-09 15:43:49 +00:00
bm_vm2_struct_big_aref_lo.rb struct: avoid all O(n) behavior on access 2014-12-09 15:43:49 +00:00
bm_vm2_struct_big_aset.rb struct: avoid all O(n) behavior on access 2014-12-09 15:43:49 +00:00
bm_vm2_struct_big_href_hi.rb add benchmarks for struct[:name] 2015-06-22 20:10:07 +00:00
bm_vm2_struct_big_href_lo.rb add benchmarks for struct[:name] 2015-06-22 20:10:07 +00:00
bm_vm2_struct_big_hset.rb add benchmarks for struct[:name] 2015-06-22 20:10:07 +00:00
bm_vm2_struct_small_aref.rb struct: avoid all O(n) behavior on access 2014-12-09 15:43:49 +00:00
bm_vm2_struct_small_aset.rb struct: avoid all O(n) behavior on access 2014-12-09 15:43:49 +00:00
bm_vm2_struct_small_href.rb add benchmarks for struct[:name] 2015-06-22 20:10:07 +00:00
bm_vm2_struct_small_hset.rb add benchmarks for struct[:name] 2015-06-22 20:10:07 +00:00
bm_vm2_super.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm2_unif1.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm2_zsuper.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm3_backtrace.rb * vm.c (frame_info_to_str): add `break'. 2012-05-26 03:25:15 +00:00
bm_vm3_clearmethodcache.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm3_gc.rb bm_vm3_gc.rb: no shebang 2015-09-29 08:03:12 +00:00
bm_vm_symbol_block_pass.rb bm_vm_symbol_block_pass.rb: rename 2015-09-29 00:21:10 +00:00
bm_vm_thread_alive_check1.rb * benchmark/bm_app_erb.rb: increase loop count. too short 2011-07-01 10:39:12 +00:00
bm_vm_thread_close.rb vm*: doubly-linked list from ccan to manage vm->living_threads 2014-05-10 23:48:51 +00:00
bm_vm_thread_create_join.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm_thread_mutex1.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm_thread_mutex2.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm_thread_mutex3.rb * benchmark/: add missing spaces around assignment operators (= and +=) for 2012-10-15 12:53:12 +00:00
bm_vm_thread_pass.rb * benchmark/bm_vm4_thread_pass.rb: rename bm_vm4* to 2011-06-14 19:30:12 +00:00
bm_vm_thread_pass_flood.rb * benchmark/bm_vm1_lvar_init.rb: added. 2012-05-27 14:41:01 +00:00
bm_vm_thread_pipe.rb * benchmark/bm_vm4_thread_pass.rb: rename bm_vm4* to 2011-06-14 19:30:12 +00:00
bm_vm_thread_queue.rb * properties. 2013-11-06 00:21:05 +00:00
driver.rb driver.rb: load-rawdata 2015-03-06 01:33:43 +00:00
make_fasta_output.rb * set eol-style. 2007-11-16 01:30:29 +00:00
prepare_require.rb * benchmark/prepare_require.rb: skip file creation if it already 2015-10-08 21:53:48 +00:00
prepare_require_thread.rb * benchmark/bm_require.rb: new benchmark for require. 2015-10-08 21:31:49 +00:00
prepare_so_count_words.rb * set eol-style. 2007-11-16 01:30:29 +00:00
prepare_so_k_nucleotide.rb * benchmark/prepare_so_k_nucleotide.rb: use require_relative. 2014-07-11 02:13:09 +00:00
prepare_so_reverse_complement.rb * benchmark/prepare_so_k_nucleotide.rb: use require_relative. 2014-07-11 02:13:09 +00:00
report.rb * remove trailing spaces. 2011-05-15 11:55:52 +00:00
run.rb * remove trailing spaces. 2011-05-15 11:55:52 +00:00
runc.rb * tool/mkconfig.rb: generate RbConfig.ruby in rbconfig.rb. 2009-12-31 15:00:04 +00:00
wc.input.base set svn:eol-style 2007-02-12 23:01:19 +00:00