Project

General

Profile

Actions

Bug #10999

closed

[PERF] bm_hash_aref_flo.rb

Added by tgxworld (Guo Xiang Tan) about 9 years ago. Updated almost 9 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.

Actions #1

Updated by nobu (Nobuyoshi Nakada) about 9 years ago

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.

Actions #2

Updated by nobu (Nobuyoshi Nakada) about 9 years ago

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

Applied in changeset r50084.


bm_hash_aref_flo.rb: fix data

Actions #3

Updated by nobu (Nobuyoshi Nakada) about 9 years ago

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

Updated by tgxworld (Guo Xiang Tan) about 9 years ago

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

Actions #5

Updated by ko1 (Koichi Sasada) about 9 years ago

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.

Actions #6

Updated by nagachika (Tomoyuki Chikanaga) almost 9 years ago

  • 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: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0