ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "tmm1 (Aman Gupta)" <ruby@tmm1.net>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:53504] [ruby-trunk - Bug #8092] [patch] gc: improve accuracy of objspace_live_num() and allocated/freed counters
Date: Mon, 18 Mar 2013 22:27:35 +0900	[thread overview]
Message-ID: <redmine.journal-37696.20130318222733@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-8092.20130314121005@ruby-lang.org


Issue #8092 has been updated by tmm1 (Aman Gupta).


This test is passing for me on trunk. Before r39811 it is failing.

[ 92/132] TestGc#test_stat                                                
{: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}
{: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}
Finished tests in 3.297242s, 40.0335 tests/s, 1313.5220 assertions/s.            
132 tests, 4331 assertions, 0 failures, 0 errors, 0 skips

ruby -v: ruby 2.1.0dev (2013-03-18 trunk 39811) [x86_64-linux]

----------------------------------------
Bug #8092: [patch] gc: improve accuracy of objspace_live_num() and allocated/freed counters
https://bugs.ruby-lang.org/issues/8092#change-37696

Author: tmm1 (Aman Gupta)
Status: Open
Priority: Normal
Assignee: authorNari (Narihiro Nakamura)
Category: core
Target version: 
ruby -v: ruby 2.1.0dev (2013-03-14 trunk 39748) [x86_64-darwin12.2.1]


Test with large rails app:

  ruby -e'
    require "./config/environment"

    stat, count = {}, {}
    GC.start
    GC.stat(stat)
    ObjectSpace.count_objects(count)

    printf "%d == %d\n", stat[:heap_live_num], count[:TOTAL]-count[:FREE]
  '

Without patch:

    632974 == 628506

With patch:

    628506 == 628506

diff --git a/gc.c b/gc.c
index bd95073..48f9470 100644
--- a/gc.c
+++ b/gc.c
@@ -1432,10 +1432,8 @@ finalize_list(rb_objspace_t *objspace, RVALUE *p)
 	run_final(objspace, (VALUE)p);
 	if (!FL_TEST(p, FL_SINGLETON)) { /* not freeing page */
             add_slot_local_freelist(objspace, p);
-            if (!is_lazy_sweeping(objspace)) {
-		objspace->total_freed_object_num++;
-		objspace->heap.free_num++;
-            }
+            objspace->total_freed_object_num++;
+            objspace->heap.free_num++;
 	}
 	else {
 	    struct heaps_slot *slot = (struct heaps_slot *)(VALUE)RDATA(p)->dmark;
@@ -1939,9 +1937,9 @@ slot_sweep(rb_objspace_t *objspace, struct heaps_slot *sweep_slot)
         else {
             sweep_slot->free_next = NULL;
         }
-	objspace->total_freed_object_num += freed_num;
 	objspace->heap.free_num += freed_num + empty_num;
     }
+    objspace->total_freed_object_num += freed_num;
     objspace->heap.final_num += final_num;
 
     if (deferred_final_list && !finalizing) {
@@ -2965,11 +2963,11 @@ rb_gc_force_recycle(VALUE p)
     rb_objspace_t *objspace = &rb_objspace;
     struct heaps_slot *slot;
 
+    objspace->total_freed_object_num++;
     if (MARKED_IN_BITMAP(GET_HEAP_BITMAP(p), p)) {
         add_slot_local_freelist(objspace, (RVALUE *)p);
     }
     else {
-	objspace->total_freed_object_num++;
 	objspace->heap.free_num++;
         slot = add_slot_local_freelist(objspace, (RVALUE *)p);
         if (slot->free_next == NULL) {



-- 
http://bugs.ruby-lang.org/

  parent reply	other threads:[~2013-03-18 13:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-14  3:10 [ruby-core:53392] [ruby-trunk - Bug #8092][Open] [patch] gc: improve accuracy of objspace_live_num() and allocated/freed counters tmm1 (Aman Gupta)
2013-03-14  7:03 ` [ruby-core:53400] [ruby-trunk - Bug #8092] " authorNari (Narihiro Nakamura)
2013-03-18  8:32 ` [ruby-core:53496] " authorNari (Narihiro Nakamura)
2013-03-18 13:27 ` tmm1 (Aman Gupta) [this message]
2013-03-18 14:16 ` [ruby-core:53505] " tmm1 (Aman Gupta)
2013-03-18 15:22 ` [ruby-core:53506] " authorNari (Narihiro Nakamura)

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-37696.20130318222733@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).