From: keithrbennett@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:102270] [Ruby master Bug#17497] Ractor performance issue
Date: Wed, 27 Jan 2021 23:49:25 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-90123.20210127234925.182@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-17497.20201231214850.182@ruby-lang.org
Issue #17497 has been updated by keithrbennett (Keith Bennett).
I've updated the software I used to measure this, and moved it to https://github.com/keithrbennett/keithrbennett-ractor-test.
----------------------------------------
Bug #17497: Ractor performance issue
https://bugs.ruby-lang.org/issues/17497#change-90123
* Author: marcandre (Marc-Andre Lafortune)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin18]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
There's a strange performance issue with Ractor (at least on MacOS, didn't run on other OS).
I ran a benchmark doing 3 different types of work:
* "fib": method calls (naive fibonacci calculation)
* "cpu": `(0...1000).inject(:+)`
* "sleep": call `sleep`
I get the kind of results I was excepting for the `fib` and for sleeping, but the results for the "cpu" workload show a problem.
It is so slow that my pure Ruby backport (using Threads) is 65x faster 😮 on my Mac Pro (despite having 6 cores). Expected results would be 6x slower, so in that case Ractor is 400x slower than it should 😿
On my MacBook (2 cores) the results are not as bad, the `cpu` workload is 3x faster with my pure-Ruby backport (only) instead of ~2x slower, so the factor is 6x too slow.
```
$ gem install backports
Successfully installed backports-3.20.0
1 gem installed
$ ruby ractor_test.rb
<internal:ractor>:267: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
fib: 110 ms | cpu: 22900 ms | sleep: 206 ms
$ B=t ruby ractor_test.rb
Using pure Ruby implementation
fib: 652 ms | cpu: 337 ms | sleep: 209 ms
```
Notice the `sleep` run takes similar time, which is good, and `fib` is ~6x faster on my 6-core CPU (and ~2x faster on my 2-core MacBook), again that's good as the pure ruby version uses Threads and thus runs with a single GVL.
The `cpu` version is the problem.
Script is here: https://gist.github.com/marcandre/bfed626e538a3d0fc7cad38dc026cf0e
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2021-01-27 23:49 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-31 21:48 [ruby-core:101840] [Ruby master Bug#17497] Ractor performance issue marcandre-ruby-core
2021-01-03 18:23 ` [ruby-core:101889] " Greg.mpls
2021-01-03 18:41 ` [ruby-core:101890] " marcandre-ruby-core
2021-01-03 20:01 ` [ruby-core:101893] " Greg.mpls
2021-01-05 4:23 ` [ruby-core:101926] " ko1
2021-01-05 4:44 ` [ruby-core:101928] " marcandre-ruby-core
2021-01-05 7:47 ` [ruby-core:101930] " ko1
2021-01-05 8:08 ` [ruby-core:101931] " ko1
2021-01-05 9:07 ` [ruby-core:101932] " ko1
2021-01-05 15:55 ` [ruby-core:101934] " marcandre-ruby-core
2021-01-06 15:41 ` [ruby-core:101963] " yura.des
2021-01-18 18:11 ` [ruby-core:102141] " keithrbennett
2021-01-27 23:49 ` keithrbennett [this message]
2021-01-29 8:41 ` [ruby-core:102286] " ko1
2021-01-29 8:46 ` [ruby-core:102287] " ko1
2021-01-29 8:47 ` [ruby-core:102288] " ko1
2021-01-31 20:57 ` [ruby-core:102339] " keithrbennett
2021-02-12 8:02 ` [ruby-core:102467] " ko1
2021-02-13 2:52 ` [ruby-core:102474] " ko1
2021-02-15 21:40 ` [ruby-core:102510] " keithrbennett
2021-03-11 11:25 ` [ruby-core:102825] " naruse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-90123.20210127234925.182@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).