Project

General

Profile

Actions

Bug #10999

closed

[PERF] bm_hash_aref_flo.rb

Bug #10999: [PERF] bm_hash_aref_flo.rb

Added by tgxworld (Guo Xiang Tan) over 10 years ago. Updated over 10 years ago.

Status:
Closed
Target version:
-
ruby -v:
2.3.0dev (2015-03-18 trunk 49999) [x86_64-linux]
[ruby-core:<unknown>]

Description

Before: 0.066s
After 3bcf9fb53e4b9efabb15a3091fddfb68e5b6fbbe: 0.094

To view the full graph, please visit http://rubybench.org/ruby/ruby/commits?result_type=hash_aref_flo&display_count=200.

To issue is meant to highlight what we're seeing at RubyBench.org, feel free to close this issue if the trade offs were intended.

Updated by nobu (Nobuyoshi Nakada) over 10 years ago Actions #1

It is not a realistic benchmark, that integer parts are all different.

Adding floats with same integer parts shows very bad result in the older version, whereas the latest version does not.

h = {}
strs = [*1..10000].map! {|i| i.fdiv(100)}
strs.each { |s| h[s] = s }
50.times { strs.each { |s| h[s] } }

benchmark results:
Execution time (sec)

name old new
hash_aref_flo 0.942 0.084

Speedup ratio: compare with the result of `old' (greater is better)

name new
hash_aref_flo 11.175

This is because the older code ignored fraction parts, and it became neary linear search.

Updated by nobu (Nobuyoshi Nakada) over 10 years ago Actions #2

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

Applied in changeset r50084.


bm_hash_aref_flo.rb: fix data

Updated by nobu (Nobuyoshi Nakada) over 10 years ago Actions #3

  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED

Updated by tgxworld (Guo Xiang Tan) over 10 years ago Actions #4

Thanks Nobu! I'll updated and backfill the new benchmark on our end as well. Thanks for looking into this!

Updated by ko1 (Koichi Sasada) over 10 years ago Actions #5

Nobuyoshi Nakada wrote:

It is not a realistic benchmark, that integer parts are all different.

Why? I think it is possible case (I agree not so much case).
Maybe it is issue on Float#hash code.

Adding different (more possible) case is nice, but modifying benchmark and solving issue is not good way. Of course, if benchmark has a bug (not intended behavior), it should be solved.

Updated by nagachika (Tomoyuki Chikanaga) over 10 years ago Actions #6

  • Backport changed from 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONE

Backported into ruby_2_2 branch at r50547.

I support ko1's comment. But I think the difference in benchmark scripts between branches are more misleading. So I backport the change.
I'm willing to backport the resurrection of the original benchmark. Please notice me by new ticket or change Backport field.

Actions

Also available in: PDF Atom