From: nobu@... Date: 2015-10-13T07:06:15+00:00 Subject: [ruby-dev:49301] [Ruby trunk - Bug #11559] ビジーループの thread と YAML.parse を組み合わせたときの実行時間が 2.2.3 で遅くなっている Issue #11559 has been updated by Nobuyoshi Nakada. ベンチマークを取ってみたのですが、どうもそれだけではないように思えます。 `-gvl`と付いているのがr50887をrevertしたバージョンです。 ----------------------------------------------------------- benchmark results: Execution time (sec) name |2.2.0 |2.2.2 |2.2.3 |2.2.3-gvl|r52118 |trunk-gvl --------------|------:|------:|------:|--------:|------:|--------: require | 3.332| 3.380| 3.679| 1.975| 1.279| 1.212 require_thread| 1.289| 1.671|100.325| 18.569| 21.528| 16.998 Speedup ratio: compare with the result of `2.2.0' (greater is better) name |2.2.2 |2.2.3 |2.2.3-gvl|r52118 |trunk-gvl --------------|------:|------:|--------:|------:|--------: require | 0.986| 0.906| 1.687| 2.606| 2.750 require_thread| 0.772| 0.013| 0.069| 0.060| 0.076 ---------------------------------------- Bug #11559: ビジーループの thread と YAML.parse を組み合わせたときの実行時間が 2.2.3 で遅くなっている https://bugs.ruby-lang.org/issues/11559#change-54437 * Author: 三村 益隆 * Status: Open * Priority: Normal * Assignee: Nobuyoshi Nakada * ruby -v: 2.2.3 * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- ビジーループするスレッドと YAML.parse を並行して実行するような以下のようなコードが 2.2.2 と 2.2.3 で、 数倍遅くなっているようです。trunk でも遅いことを確認してます。 ~~~ require 'thread' require 'yaml' puts RUBY_VERSION y = (1..1000).to_a.to_yaml t = Thread.new do while true; 1;end end 10.times do YAML.load(y) end t.kill ~~~ 実行結果 ~~~ $ time ruby thread_loop_with_while.rb 2.2.2 ruby thread_loop_with_while.rb 0.30s user 0.06s system 94% cpu 0.375 total $ time ruby thread_loop_with_loop.rb 2.2.3 ruby thread_loop_with_loop.rb 1.80s user 0.05s system 99% cpu 1.864 total ~~~ -- https://bugs.ruby-lang.org/