https://bugs.ruby-lang.org/
https://bugs.ruby-lang.org/favicon.ico?1711330511
2013-03-14T16:02:08Z
Ruby Issue Tracking System
Ruby master - Bug #8092: [patch] gc: improve accuracy of objspace_live_num() and allocated/freed counters
https://bugs.ruby-lang.org/issues/8092?journal_id=37592
2013-03-14T16:02:08Z
authorNari (Narihiro Nakamura)
authorNari@gmail.com
<ul><li><strong>Category</strong> set to <i>core</i></li><li><strong>Assignee</strong> set to <i>authorNari (Narihiro Nakamura)</i></li></ul>
Ruby master - Bug #8092: [patch] gc: improve accuracy of objspace_live_num() and allocated/freed counters
https://bugs.ruby-lang.org/issues/8092?journal_id=37690
2013-03-18T17:32:51Z
authorNari (Narihiro Nakamura)
authorNari@gmail.com
<ul></ul><p>Thank you for bug report.</p>
<p>But, the following test case is failure.</p>
<p>I think ko1-san is the implementer of GC.stat.<br>
ko1-san, what do you think?</p>
<p>=== start ===<br>
$ git diff test<br>
diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb<br>
index bed58f3..8cb036a 100644<br>
--- a/test/ruby/test_gc.rb<br>
+++ b/test/ruby/test_gc.rb<br>
@@ -64,6 +64,15 @@ class TestGc < Test::Unit::TestCase<br>
assert_equal(arg, res)<br>
assert_equal(false, res.empty?)<br>
assert_kind_of(Integer, res[:count])<br>
+</p>
<ul>
<li>stat, count = {}, {}</li>
<li>GC.start</li>
<li>GC.stat(stat)</li>
<li>ObjectSpace.count_objects(count)</li>
<li>puts ""</li>
<li>p stat</li>
<li>p count</li>
<li>assert_equal(stat[:heap_live_num], count[:TOTAL]-count[:FREE])<br>
end</li>
</ul>
<p>def test_singleton_method</p>
<p>$ % make test-all TESTS='ruby/test_defined.rb ruby/test_integer.rb ruby/test_objectspace.rb ruby/test_sprintf_comb.rb ruby/test_argf.rb ruby/test_fiber.rb ruby/test_gc.rb'<br>
....</p>
<a name="Running-tests"></a>
<h1 >Running tests:<a href="#Running-tests" class="wiki-anchor">¶</a></h1>
<p>[ 91/131] TestGc#test_stat<br>
{:count=>351, :heap_used=>684, :heap_length=>1139, :heap_increment=>399, :heap_live_num=>46061, :heap_free_num=>152639, :heap_final_num=>0, :total_allocated_object=>402509, :total_freed_object=>356448}<br>
{:TOTAL=>198553, :FREE=>152639, :T_OBJECT=>31312, :T_CLASS=>655, :T_MODULE=>56, :T_FLOAT=>10, :T_STRING=>8425, :T_REGEXP=>146, :T_ARRAY=>1966, :T_HASH=>49, :T_STRUCT=>10, :T_BIGNUM=>25, :T_FILE=>10, :T_DATA=>2225, :T_MATCH=>22, :T_COMPLEX=>1, :T_NODE=>934, :T_ICLASS=>68}<br>
= 0.01 s</p>
<ol>
<li>Failure:<br>
test_stat(TestGc) [/home/nari/source/ruby/ruby-git/test/ruby/test_gc.rb:75]:<br>
<46061> expected but was<br>
<45914>.</li>
</ol>
<p>Finished tests in 6.628281s, 19.7638 tests/s, 657.9383 assertions/s.<br>
131 tests, 4361 assertions, 1 failures, 0 errors, 0 skips</p>
<p>ruby -v: ruby 2.1.0dev (2013-03-14 trunk 38552) [x86_64-linux]<br>
make: *** [yes-test-all] Error 1<br>
=== end ===</p>
Ruby master - Bug #8092: [patch] gc: improve accuracy of objspace_live_num() and allocated/freed counters
https://bugs.ruby-lang.org/issues/8092?journal_id=37696
2013-03-18T22:27:33Z
tmm1 (Aman Karmani)
ruby@tmm1.net
<ul></ul><p>This test is passing for me on trunk. Before r39811 it is failing.</p>
<p>[ 92/132] TestGc#test_stat<br>
{:count=>357, :heap_used=>421, :heap_length=>811, :heap_increment=>283, :heap_live_num=>14452, :heap_free_num=>156816, :heap_final_num=>0, :total_allocated_object=>389190, :total_freed_object=>374738}<br>
{:TOTAL=>171268, :FREE=>156816, :T_OBJECT=>46, :T_CLASS=>655, :T_MODULE=>56, :T_FLOAT=>10, :T_STRING=>8268, :T_REGEXP=>145, :T_ARRAY=>1947, :T_HASH=>42, :T_STRUCT=>9, :T_BIGNUM=>25, :T_FILE=>3, :T_DATA=>2221, :T_MATCH=>21, :T_COMPLEX=>1, :T_NODE=>935, :T_ICLASS=>68}<br>
Finished tests in 3.297242s, 40.0335 tests/s, 1313.5220 assertions/s.<br>
132 tests, 4331 assertions, 0 failures, 0 errors, 0 skips</p>
<p>ruby -v: ruby 2.1.0dev (2013-03-18 trunk 39811) [x86_64-linux]</p>
Ruby master - Bug #8092: [patch] gc: improve accuracy of objspace_live_num() and allocated/freed counters
https://bugs.ruby-lang.org/issues/8092?journal_id=37697
2013-03-18T23:16:20Z
tmm1 (Aman Karmani)
ruby@tmm1.net
<ul></ul><p>With this updated patch the test is passing both before and after r39811. Problem was in finalize_list. After r39811 removing heap is less common, so the failure did not appear.</p>
<p>diff --git a/gc.c b/gc.c<br>
index 2afd311..e72b198 100644<br>
--- a/gc.c<br>
+++ b/gc.c<br>
@@ -1431,12 +1431,10 @@ finalize_list(rb_objspace_t *objspace, RVALUE *p)<br>
while (p) {<br>
RVALUE *tmp = p->as.free.next;<br>
run_final(objspace, (VALUE)p);</p>
<ul>
<li>objspace->total_freed_object_num++;<br>
if (!FL_TEST(p, FL_SINGLETON)) { /* not freeing page */<br>
add_slot_local_freelist(objspace, p);</li>
</ul>
<ul>
<li>
<pre><code> if (!is_lazy_sweeping(objspace)) {
</code></pre>
</li>
<li>
<pre><code> objspace->total_freed_object_num++;
</code></pre>
</li>
<li>
<pre><code> objspace->heap.free_num++;
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> objspace->heap.free_num++;
</code></pre>
}<br>
else {<br>
struct heaps_slot *slot = (struct heaps_slot *)(VALUE)RDATA(p)->dmark;<br>
@@ -1940,9 +1938,9 @@ slot_sweep(rb_objspace_t *objspace, struct heaps_slot *sweep_slot)<br>
else {<br>
sweep_slot->free_next = NULL;<br>
}</li>
</ul>
<ul>
<li>objspace->total_freed_object_num += freed_num;<br>
objspace->heap.free_num += freed_num + empty_num;<br>
}</li>
</ul>
<ul>
<li>
<p>objspace->total_freed_object_num += freed_num;<br>
objspace->heap.final_num += final_num;</p>
<p>if (deferred_final_list && !finalizing) {<br>
@@ -2969,11 +2967,11 @@ rb_gc_force_recycle(VALUE p)<br>
rb_objspace_t *objspace = &rb_objspace;<br>
struct heaps_slot *slot;</p>
</li>
<li>
<p>objspace->total_freed_object_num++;<br>
if (MARKED_IN_BITMAP(GET_HEAP_BITMAP(p), p)) {<br>
add_slot_local_freelist(objspace, (RVALUE *)p);<br>
}<br>
else {</p>
</li>
</ul>
<ul>
<li>objspace->total_freed_object_num++;<br>
objspace->heap.free_num++;<br>
slot = add_slot_local_freelist(objspace, (RVALUE *)p);<br>
if (slot->free_next == NULL) {<br>
diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb<br>
index 90c4787..b1e52fc 100644<br>
--- a/test/ruby/test_gc.rb<br>
+++ b/test/ruby/test_gc.rb<br>
@@ -64,6 +64,12 @@ class TestGc < Test::Unit::TestCase<br>
assert_equal(arg, res)<br>
assert_equal(false, res.empty?)<br>
assert_kind_of(Integer, res[:count])</li>
</ul>
<ul>
<li>
<li>stat, count = {}, {}</li>
<li>GC.start</li>
<li>GC.stat(stat)</li>
<li>ObjectSpace.count_objects(count)</li>
<li>assert_equal(count[:TOTAL]-count[:FREE], stat[:heap_live_num])<br>
end</li>
</ul>
<p>def test_singleton_method</p>
Ruby master - Bug #8092: [patch] gc: improve accuracy of objspace_live_num() and allocated/freed counters
https://bugs.ruby-lang.org/issues/8092?journal_id=37698
2013-03-19T00:22:17Z
authorNari (Narihiro Nakamura)
authorNari@gmail.com
<ul></ul><p>Wow, thanks!! I'll commit it soon.</p>
Ruby master - Bug #8092: [patch] gc: improve accuracy of objspace_live_num() and allocated/freed counters
https://bugs.ruby-lang.org/issues/8092?journal_id=37699
2013-03-19T00:30:09Z
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 r39812.<br>
Aman, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<hr>
<ul>
<li>gc.c: Improve accuracy of objspace_live_num() and<br>
allocated/freed counters. patched by tmm1(Aman Gupta).<br>
[Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: [patch] gc: improve accuracy of objspace_live_num() and allocated/freed counters (Closed)" href="https://bugs.ruby-lang.org/issues/8092">#8092</a>] <a href="/issues/8092">[ruby-core:53392]</a></li>
</ul>