[#80531] Re: [ruby-cvs:65407] normal:r58236 (trunk): thread.c: comments on M:N threading [ci skip] — Eric Wong <normalperson@...>

SASADA Koichi <ko1@ruby-lang.org> wrote:

24 messages 2017/04/02
[#80532] Re: [ruby-cvs:65407] normal:r58236 (trunk): thread.c: comments on M:N threading [ci skip] — SASADA Koichi <ko1@...> 2017/04/02

On 2017/04/02 11:35, Eric Wong wrote:

[#80540] Re: [ruby-cvs:65407] normal:r58236 (trunk): thread.c: comments on M:N threading [ci skip] — Eric Wong <normalperson@...> 2017/04/03

SASADA Koichi <ko1@atdot.net> wrote:

[#81027] Re: [ruby-cvs:65407] normal:r58236 (trunk): thread.c: comments on M:N threading [ci skip] — Eric Wong <normalperson@...> 2017/05/08

Eric Wong <normalperson@yhbt.net> wrote:

[#81028] Re: [ruby-cvs:65407] normal:r58236 (trunk): thread.c: comments on M:N threading [ci skip] — SASADA Koichi <ko1@...> 2017/05/08

On 2017/05/08 9:33, Eric Wong wrote:

[#81029] Re: [ruby-cvs:65407] normal:r58236 (trunk): thread.c: comments on M:N threading [ci skip] — SASADA Koichi <ko1@...> 2017/05/08

On 2017/05/08 10:53, SASADA Koichi wrote:

[#81031] Re: [ruby-cvs:65407] normal:r58236 (trunk): thread.c: comments on M:N threading [ci skip] — Eric Wong <normalperson@...> 2017/05/08

SASADA Koichi <ko1@atdot.net> wrote:

[#81033] Re: [ruby-cvs:65407] normal:r58236 (trunk): thread.c: comments on M:N threading [ci skip] — SASADA Koichi <ko1@...> 2017/05/08

On 2017/05/08 12:01, Eric Wong wrote:

[#81035] Re: [ruby-cvs:65407] normal:r58236 (trunk): thread.c: comments on M:N threading [ci skip] — Eric Wong <normalperson@...> 2017/05/08

SASADA Koichi <ko1@atdot.net> wrote:

[#81042] Re: [ruby-cvs:65407] normal:r58236 (trunk): thread.c: comments on M:N threading [ci skip] — SASADA Koichi <ko1@...> 2017/05/09

On 2017/05/08 15:36, Eric Wong wrote:

[#81044] Re: [ruby-cvs:65407] normal:r58236 (trunk): thread.c: comments on M:N threading [ci skip] — Eric Wong <normalperson@...> 2017/05/09

SASADA Koichi <ko1@atdot.net> wrote:

[#81045] Re: [ruby-cvs:65407] normal:r58236 (trunk): thread.c: comments on M:N threading [ci skip] — SASADA Koichi <ko1@...> 2017/05/09

On 2017/05/09 12:38, Eric Wong wrote:

[#81047] Re: [ruby-cvs:65407] normal:r58236 (trunk): thread.c: comments on M:N threading [ci skip] — Eric Wong <normalperson@...> 2017/05/09

SASADA Koichi <ko1@atdot.net> wrote:

[ruby-core:80855] [Ruby trunk Bug#13506] Improve performance of Complex#{+, -, *, /, **, abs2}

From: watson1978@...
Date: 2017-04-25 05:25:36 UTC
List: ruby-core #80855
Issue #13506 has been reported by watson1978 (Shizuo Fujita).

----------------------------------------
Bug #13506: Improve performance of Complex#{+,-,*,/,**,abs2}
https://bugs.ruby-lang.org/issues/13506

* Author: watson1978 (Shizuo Fujita)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
At the internal calculation in Complex methods,
it will just call Ruby #{+,-,*,/} methods via rb_funcall().

This patch will provide the optimization path for calculation
using #{+,-,/,*} methods for internal Fixnum objects.

### Before
~~~
Calculating -------------------------------------
           Complex#+      5.186M (賊 4.9%) i/s -     25.937M in   5.013851s
           Complex#-      5.209M (賊 5.9%) i/s -     26.038M in   5.017972s
           Complex#*      3.211M (賊 5.2%) i/s -     16.170M in   5.051605s
           Complex#/    537.251k (賊 3.9%) i/s -      2.691M in   5.017513s
          Complex#**      1.540M (賊 3.0%) i/s -      7.726M in   5.019918s
        Complex#abs2      7.050M (賊 7.9%) i/s -     35.047M in   5.009324s
~~~

### After
~~~
Calculating -------------------------------------
           Complex#+      7.265M (賊 4.6%) i/s -     36.341M in   5.013803s
           Complex#-      7.310M (賊 4.5%) i/s -     36.540M in   5.009521s
           Complex#*      6.402M (賊 4.0%) i/s -     32.060M in   5.016835s
           Complex#/    541.564k (賊 3.3%) i/s -      2.744M in   5.072620s
          Complex#**      1.490M (賊 4.0%) i/s -      7.506M in   5.046460s
        Complex#abs2     17.799M (賊 6.6%) i/s -     88.688M in   5.007732s
~~~

### Test code
~~~
require 'benchmark/ips'

Benchmark.ips do |x|
  c1 = Complex(2, 3)
  c2 = Complex(2, 3)

  x.report "Complex#+" do |t|
    t.times { c1 + c2 }
  end

  x.report "Complex#-" do |t|
    t.times { c1 - c2 }
  end

  x.report "Complex#*" do |t|
    t.times { c1 * c2 }
  end

  x.report "Complex#/" do |t|
    t.times { c1 / c2 }
  end

  x.report "Complex#**" do |t|
    t.times { c1 ** c2 }
  end

  x.report "Complex#abs2" do |t|
    t.times { c1.abs2 }
  end
end
~~~

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




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

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next