From: keithrbennett@... Date: 2021-01-31T20:57:03+00:00 Subject: [ruby-core:102339] [Ruby master Bug#17497] Ractor performance issue Issue #17497 has been updated by keithrbennett (Keith Bennett). @ko1 - My apologies for not responding sooner. I guess I have not configured this forum correctly to receive notifications, I'll look into that. I've tested my benchmark against Ruby head, and performance with multiple cores seem to have degraded. Perhaps I have made an error in my approaches, I don't know. I will paste my results below. My OS is "Ubuntu 20.04.2 LTS" (Kubuntu). In case it's useful, I've made my script easier to use; it automatically tests and compares 1 ractor with (CPU_count) ractors. You can find it at https://github.com/keithrbennett/keithrbennett-ractor-test/blob/master/ractor-file-strings-test.rb. Information about configuring it, what it does, etc., is included in comments at the top of the script. ``` Small Data Set: Ruby 3.0.0: 1 CPU 24 CPU's Factor ---------------------------------------------------------------- User 6.75500 52.34200 7.74863 System 0.00000 0.02800 0.00415 Total 6.83900 52.40700 7.66296 Real 6.83300 4.10500 0.60076 2021-01-31 Ruby head (ruby 3.1.0dev (2021-01-31T09:48:28Z master 22b8ddfd10) [x86_64-linux]): 1 CPU 24 CPU's Factor ---------------------------------------------------------------- User 6.18000 56.27400 9.10583 System 0.00400 0.02800 0.00453 Total 6.26800 56.34200 8.98883 Real 6.26100 4.26200 0.68072 ================================================================ Larger Data Set: Ruby 3.0.0: 1 CPU 24 CPU's Factor ---------------------------------------------------------------- User 51.01000 499.67200 9.79557 System 0.04000 0.25900 0.00508 Total 51.32300 500.12900 9.74473 Real 51.31200 45.56600 0.88802 2021-01-31 Ruby head (ruby 3.1.0dev (2021-01-31T09:48:28Z master 22b8ddfd10) [x86_64-linux]): 1 CPU 24 CPU's Factor ---------------------------------------------------------------- User 47.08900 486.34400 10.32819 System 0.03200 0.20300 0.00431 Total 47.39500 486.74800 10.27003 Real 47.38400 43.95100 0.92755 ``` ---------------------------------------- Bug #17497: Ractor performance issue https://bugs.ruby-lang.org/issues/17497#change-90194 * Author: marcandre (Marc-Andre Lafortune) * Status: Closed * 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 :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/ Unsubscribe: