ruby-dev (Japanese) list archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-dev:50045] [Ruby trunk Bug#13368] Improve performance of Array#sum with float elements
       [not found] <redmine.issue-13368.20170327035053@ruby-lang.org>
@ 2017-03-27  3:50 ` watson1978
  2017-04-10 18:51   ` [ruby-dev:50067] " Eric Wong
  2017-04-14  6:45 ` [ruby-dev:50075] " watson1978
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 6+ messages in thread
From: watson1978 @ 2017-03-27  3:50 UTC (permalink / raw
  To: ruby-dev

Issue #13368 has been reported by watson1978 (Shizuo Fujita).

----------------------------------------
Bug #13368: Improve performance of Array#sum with float elements
https://bugs.ruby-lang.org/issues/13368

* Author: watson1978 (Shizuo Fujita)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
The declaration of local variable in loop, it will initialize local variable for each run of the loop with clang generated code.
So, it shouldn't declare the local variable in heavy loop.

Array#sum with float elements will be faster around 30%.

### Before
~~~
       user     system      total        real
   3.320000   0.010000   3.330000 (  3.336088)
~~~

### After
~~~
       user     system      total        real
   2.590000   0.010000   2.600000 (  2.602399)
~~~

### Test code
~~~
require 'benchmark'

Benchmark.bmbm do |x|
  ary = []
  10000.times { ary << Random.rand }

  x.report do
    50000.times do
      ary.sum
    end
  end

end
~~~

### Patch
https://github.com/ruby/ruby/pull/1555



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-dev:50067] Re: [Ruby trunk Bug#13368] Improve performance of Array#sum with float elements
  2017-03-27  3:50 ` [ruby-dev:50045] [Ruby trunk Bug#13368] Improve performance of Array#sum with float elements watson1978
@ 2017-04-10 18:51   ` Eric Wong
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Wong @ 2017-04-10 18:51 UTC (permalink / raw
  To: ruby-dev; +Cc: ruby-core

+Cc ruby-core since the original post was English

watson1978@gmail•com wrote:
> Issue #13368 has been reported by watson1978 (Shizuo Fujita).
> 
> ----------------------------------------
> Bug #13368: Improve performance of Array#sum with float elements
> https://bugs.ruby-lang.org/issues/13368

> The declaration of local variable in loop, it will initialize local variable for each run of the loop with clang generated code.
> So, it shouldn't declare the local variable in heavy loop.

I disagree with this change.  Different compilers optimize
differently.

> ### Patch
> https://github.com/ruby/ruby/pull/1555

Disclaimer: I used commit 3635f883096604d0e6453dc9d2484d5c92467109
after having:

	fetch = +refs/pull/*:refs/remotes/ruby/pull/*

In the [remote ] section of my .git/config and did not
use any proprietary JavaScript or browser to apply your change.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-dev:50075] [Ruby trunk Bug#13368] Improve performance of Array#sum with float elements
       [not found] <redmine.issue-13368.20170327035053@ruby-lang.org>
  2017-03-27  3:50 ` [ruby-dev:50045] [Ruby trunk Bug#13368] Improve performance of Array#sum with float elements watson1978
@ 2017-04-14  6:45 ` watson1978
  2017-04-14  7:30 ` [ruby-dev:50076] " naruse
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: watson1978 @ 2017-04-14  6:45 UTC (permalink / raw
  To: ruby-dev

Issue #13368 has been updated by watson1978 (Shizuo Fujita).


When I filed this ticket, I tried to run benchmark on macOS + clang only.
Then, I tried to do on 2 environments in additional.

I found what my patch is effective with clang envrionment only (such as macOS or FreeBSD which use clang as default compiler).

## macOS 10.12 + gcc 6.3.0
### Before
~~~
       user     system      total        real
   2.750000   0.000000   2.750000 (  2.757864)
~~~

### After
~~~
       user     system      total        real
   2.730000   0.010000   2.740000 (  2.740204)
~~~

## Ubuntu 16.04.4 + gcc 5.4.0
### Before
~~~
       user     system      total        real
   2.400000   0.000000   2.400000 (  2.395856)
~~~

### After
~~~
       user     system      total        real
   2.330000   0.000000   2.330000 (  2.327889)
~~~


----------------------------------------
Bug #13368: Improve performance of Array#sum with float elements
https://bugs.ruby-lang.org/issues/13368#change-64225

* Author: watson1978 (Shizuo Fujita)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
The declaration of local variable in loop, it will initialize local variable for each run of the loop with clang generated code.
So, it shouldn't declare the local variable in heavy loop.

Array#sum with float elements will be faster around 30%.

### Before
~~~
       user     system      total        real
   3.320000   0.010000   3.330000 (  3.336088)
~~~

### After
~~~
       user     system      total        real
   2.590000   0.010000   2.600000 (  2.602399)
~~~

### Test code
~~~
require 'benchmark'

Benchmark.bmbm do |x|
  ary = []
  10000.times { ary << Random.rand }

  x.report do
    50000.times do
      ary.sum
    end
  end

end
~~~

### Patch
https://github.com/ruby/ruby/pull/1555



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-dev:50076] [Ruby trunk Bug#13368] Improve performance of Array#sum with float elements
       [not found] <redmine.issue-13368.20170327035053@ruby-lang.org>
  2017-03-27  3:50 ` [ruby-dev:50045] [Ruby trunk Bug#13368] Improve performance of Array#sum with float elements watson1978
  2017-04-14  6:45 ` [ruby-dev:50075] " watson1978
@ 2017-04-14  7:30 ` naruse
  2017-04-14  9:04 ` [ruby-dev:50078] " watson1978
  2017-05-19 19:58 ` [ruby-dev:50131] " naruse
  4 siblings, 0 replies; 6+ messages in thread
From: naruse @ 2017-04-14  7:30 UTC (permalink / raw
  To: ruby-dev

Issue #13368 has been updated by naruse (Yui NARUSE).


watson1978 (Shizuo Fujita) wrote:
> When I filed this ticket, I tried to run benchmark on macOS + clang only.
> Then, I tried to do on 2 environments in additional.
> 
> I found what my patch is effective with clang envrionment only (such as macOS or FreeBSD which use clang as default compiler).

Hmm, the result shows clang is not efficient as gcc yet this time.
And improvement should be done by clang, not us.
Or should be done by something cleaner patch.

----------------------------------------
Bug #13368: Improve performance of Array#sum with float elements
https://bugs.ruby-lang.org/issues/13368#change-64227

* Author: watson1978 (Shizuo Fujita)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
The declaration of local variable in loop, it will initialize local variable for each run of the loop with clang generated code.
So, it shouldn't declare the local variable in heavy loop.

Array#sum with float elements will be faster around 30%.

### Before
~~~
       user     system      total        real
   3.320000   0.010000   3.330000 (  3.336088)
~~~

### After
~~~
       user     system      total        real
   2.590000   0.010000   2.600000 (  2.602399)
~~~

### Test code
~~~
require 'benchmark'

Benchmark.bmbm do |x|
  ary = []
  10000.times { ary << Random.rand }

  x.report do
    50000.times do
      ary.sum
    end
  end

end
~~~

### Patch
https://github.com/ruby/ruby/pull/1555



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-dev:50078] [Ruby trunk Bug#13368] Improve performance of Array#sum with float elements
       [not found] <redmine.issue-13368.20170327035053@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2017-04-14  7:30 ` [ruby-dev:50076] " naruse
@ 2017-04-14  9:04 ` watson1978
  2017-05-19 19:58 ` [ruby-dev:50131] " naruse
  4 siblings, 0 replies; 6+ messages in thread
From: watson1978 @ 2017-04-14  9:04 UTC (permalink / raw
  To: ruby-dev

Issue #13368 has been updated by watson1978 (Shizuo Fujita).


naruse (Yui NARUSE) wrote:
> Hmm, the result shows clang is not efficient as gcc yet this time.
> And improvement should be done by clang, not us.
> Or should be done by something cleaner patch.

Could you report this to clang developer If you don't want to fix this ?

----------------------------------------
Bug #13368: Improve performance of Array#sum with float elements
https://bugs.ruby-lang.org/issues/13368#change-64230

* Author: watson1978 (Shizuo Fujita)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
The declaration of local variable in loop, it will initialize local variable for each run of the loop with clang generated code.
So, it shouldn't declare the local variable in heavy loop.

Array#sum with float elements will be faster around 30%.

### Before
~~~
       user     system      total        real
   3.320000   0.010000   3.330000 (  3.336088)
~~~

### After
~~~
       user     system      total        real
   2.590000   0.010000   2.600000 (  2.602399)
~~~

### Test code
~~~
require 'benchmark'

Benchmark.bmbm do |x|
  ary = []
  10000.times { ary << Random.rand }

  x.report do
    50000.times do
      ary.sum
    end
  end

end
~~~

### Patch
https://github.com/ruby/ruby/pull/1555



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-dev:50131] [Ruby trunk Bug#13368] Improve performance of Array#sum with float elements
       [not found] <redmine.issue-13368.20170327035053@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2017-04-14  9:04 ` [ruby-dev:50078] " watson1978
@ 2017-05-19 19:58 ` naruse
  4 siblings, 0 replies; 6+ messages in thread
From: naruse @ 2017-05-19 19:58 UTC (permalink / raw
  To: ruby-dev

Issue #13368 has been updated by naruse (Yui NARUSE).


watson1978 (Shizuo Fujita) wrote:
> naruse (Yui NARUSE) wrote:
> > Hmm, the result shows clang is not efficient as gcc yet this time.
> > And improvement should be done by clang, not us.
> > Or should be done by something cleaner patch.
> 
> Could you report this to clang developer If you don't want to fix this ?

Though I reported to clang when it breaks build like https://bugs.llvm.org//show_bug.cgi?id=8319
Clang is considered still development at performance like other inline threshold ones.
They should improve more general cases.

----------------------------------------
Bug #13368: Improve performance of Array#sum with float elements
https://bugs.ruby-lang.org/issues/13368#change-64965

* Author: watson1978 (Shizuo Fujita)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
The declaration of local variable in loop, it will initialize local variable for each run of the loop with clang generated code.
So, it shouldn't declare the local variable in heavy loop.

Array#sum with float elements will be faster around 30%.

### Before
~~~
       user     system      total        real
   3.320000   0.010000   3.330000 (  3.336088)
~~~

### After
~~~
       user     system      total        real
   2.590000   0.010000   2.600000 (  2.602399)
~~~

### Test code
~~~
require 'benchmark'

Benchmark.bmbm do |x|
  ary = []
  10000.times { ary << Random.rand }

  x.report do
    50000.times do
      ary.sum
    end
  end

end
~~~

### Patch
https://github.com/ruby/ruby/pull/1555



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-05-19 19:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-13368.20170327035053@ruby-lang.org>
2017-03-27  3:50 ` [ruby-dev:50045] [Ruby trunk Bug#13368] Improve performance of Array#sum with float elements watson1978
2017-04-10 18:51   ` [ruby-dev:50067] " Eric Wong
2017-04-14  6:45 ` [ruby-dev:50075] " watson1978
2017-04-14  7:30 ` [ruby-dev:50076] " naruse
2017-04-14  9:04 ` [ruby-dev:50078] " watson1978
2017-05-19 19:58 ` [ruby-dev:50131] " naruse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).