From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 4086517CE74D for ; Mon, 18 Mar 2013 22:51:29 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 00D76EA6C08 for ; Mon, 18 Mar 2013 22:29:40 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (localhost.nagaokaut.ac.jp [127.0.0.1]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id E9EC397A827 for ; Mon, 18 Mar 2013 22:29:39 +0900 (JST) X-Virus-Scanned: amavisd-new at nagaokaut.ac.jp Received: from funfun.nagaokaut.ac.jp ([127.0.0.1]) by funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Kjd_kDmav6Qf for ; Mon, 18 Mar 2013 22:29:39 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id C531D97A820 for ; Mon, 18 Mar 2013 22:29:39 +0900 (JST) Received: from carbon.ruby-lang.org (carbon.ruby-lang.org [221.186.184.68]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id D28B195241B for ; Mon, 18 Mar 2013 22:29:36 +0900 (JST) Received: from beryllium.ruby-lang.org (beryllium.ruby-lang.org [127.0.0.1]) by carbon.ruby-lang.org (Postfix) with ESMTP id C5AB43C22949F; Mon, 18 Mar 2013 22:27:35 +0900 (JST) Received: from fluorine.ruby-lang.org (www.rubyist.net [210.251.121.216]) by carbon.ruby-lang.org (Postfix) with ESMTP id 330923C22949C for ; Mon, 18 Mar 2013 22:27:34 +0900 (JST) Received: from ruby-lang.org (localhost [127.0.0.1]) by fluorine.ruby-lang.org (Postfix) with ESMTP id 13B1B3E003 for ; Mon, 18 Mar 2013 22:27:34 +0900 (JST) Delivered-To: ruby-core@ruby-lang.org Date: Mon, 18 Mar 2013 22:27:35 +0900 Posted: Mon, 18 Mar 2013 22:27:33 +0900 From: "tmm1 (Aman Gupta)" Reply-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 To: ruby-core@ruby-lang.org Message-Id: References: X-ML-Name: ruby-core X-Mail-Count: 53504 X-MLServer: fml [fml 4.0.3 release (20011202/4.0.3)]; post only (only members can post) X-ML-Info: If you have a question, send e-mail with the body "help" (without quotes) to the address ruby-core-ctl@ruby-lang.org; help= X-Mailer: Redmine X-Redmine-Issue-Author: tmm1 X-Redmine-Issue-Assignee: authorNari X-Auto-Response-Suppress: OOF X-Redmine-Issue-Id: 8092 X-Redmine-Mailinglistintegration-Message-Ids: 26664 X-Redmine-Project: ruby-trunk Auto-Submitted: auto-generated X-Redmine-Site: Ruby Issue Tracking System X-Redmine-Host: bugs.ruby-lang.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Precedence: bulk List-Id: ruby-core.ruby-lang.org List-Software: fml [fml 4.0.3 release (20011202/4.0.3)] List-Post: List-Owner: List-Help: List-Unsubscribe: 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/