https://bugs.ruby-lang.org/
https://bugs.ruby-lang.org/favicon.ico?1711330511
2011-08-01T09:43:41Z
Ruby Issue Tracking System
Ruby master - Bug #5127: ruby 1.9.3 prev1 で Array#[]=( Array.new ) が1.9.2より2倍遅い
https://bugs.ruby-lang.org/issues/5127?journal_id=19881
2011-08-01T09:43:41Z
kosaki (Motohiro KOSAKI)
kosaki.motohiro@gmail.com
<ul><li><strong>Target version</strong> set to <i>1.9.3</i></li></ul><p>重要な問題だと思いますので、チケット化しました。</p>
Ruby master - Bug #5127: ruby 1.9.3 prev1 で Array#[]=( Array.new ) が1.9.2より2倍遅い
https://bugs.ruby-lang.org/issues/5127?journal_id=19882
2011-08-01T10:12:20Z
nagachika (Tomoyuki Chikanaga)
nagachika00@gmail.com
<ul></ul><p>Linux(Ubuntu 10.4 gcc 4.4.3) でも試してみたところやはり倍近く時間がかかっていました。1.9.3 ではなく trunk とですが。</p>
<p>$ ruby-1.9.2 bm_array.rb<br>
user system total real<br>
Array.new 2.340000 0.070000 2.410000 ( 2.427617)<br>
Array#[]= with Array 23.850000 1.220000 25.070000 ( 25.506229)</p>
<p>$ ruby-trunk bm_array.rb<br>
user system total real<br>
Array.new 2.200000 0.930000 3.130000 ( 3.161638)<br>
Array#[]= with Array 44.950000 1.250000 46.200000 ( 46.584050)</p>
<p>ためしに以下のように GC を切ってみるとほぼ同じくらいになりました。ついでに一時オブジェクトの生成数が増えてるんじゃないかと ObjectSpace.each_object の返す数も出してみましたが特に増えていないので、主に GC の影響でしょうか。とりあえずご報告まで。</p>
<p>$ cat bm_array.rb<br>
require 'benchmark'</p>
<p>Benchmark.bm(22) do |x|<br>
GC.disable<br>
x.report "Array.new" do<br>
1_000_000.times do<br>
Array.new(100)<br>
end<br>
end<br>
puts "objects count = #{ ObjectSpace.each_object{} }"<br>
GC.enable<br>
GC.start<br>
GC.disable<br>
x.report "Array#[]= with Array" do<br>
a = Array.new(1_000_000)<br>
1_000_000.times do |i|<br>
a[i] = Array.new(100)<br>
end<br>
end<br>
puts "objects count = #{ ObjectSpace.each_object{} }"<br>
end</p>
<p>$ ruby-1.9.2 bm_array.rb<br>
user system total real<br>
Array.new 1.470000 1.220000 2.690000 ( 2.705700)<br>
objects count = 1007204<br>
Array#[]= with Array 1.910000 0.030000 1.940000 ( 2.055783)<br>
objects count = 1003992</p>
<p>$ ruby-trunk bm_array.rb<br>
user system total real<br>
Array.new 1.510000 1.230000 2.740000 ( 2.753933)<br>
objects count = 1005182<br>
Array#[]= with Array 1.940000 0.010000 1.950000 ( 1.977659)<br>
objects count = 1002551</p>
Ruby master - Bug #5127: ruby 1.9.3 prev1 で Array#[]=( Array.new ) が1.9.2より2倍遅い
https://bugs.ruby-lang.org/issues/5127?journal_id=20152
2011-08-08T17:11:52Z
authorNari (Narihiro Nakamura)
authorNari@gmail.com
<ul><li><strong>Assignee</strong> set to <i>authorNari (Narihiro Nakamura)</i></li></ul><p>GCの問題のようですので、引き取ります。</p>
Ruby master - Bug #5127: ruby 1.9.3 prev1 で Array#[]=( Array.new ) が1.9.2より2倍遅い
https://bugs.ruby-lang.org/issues/5127?journal_id=20174
2011-08-09T13:26:16Z
authorNari (Narihiro Nakamura)
authorNari@gmail.com
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>This issue was solved with changeset r32894.<br>
, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<hr>
<ul>
<li>
<p>gc.c (gc_lazy_sweep): if sweep target slots are not found, we<br>
try heap_increment() because it might be able to expand the<br>
heap. [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: ruby 1.9.3 prev1 で Array#[]=( Array.new ) が1.9.2より2倍遅い (Closed)" href="https://bugs.ruby-lang.org/issues/5127">#5127</a>] <a href="/issues/5127">[ruby-dev:44285]</a></p>
</li>
<li>
<p>gc.c (gc_clear_mark_on_sweep_slots): if a sweeping was<br>
interrupted, we expand the heap if at all possible.</p>
</li>
</ul>