[前][次][番号順一覧][スレッド一覧]

ruby-changes:31795

From: ko1 <ko1@a...>
Date: Wed, 27 Nov 2013 15:10:01 +0900 (JST)
Subject: [ruby-changes:31795] ko1:r43874 (trunk): * gc.c (gc_stat): add new information heap_eden_page_length and

ko1	2013-11-27 15:09:55 +0900 (Wed, 27 Nov 2013)

  New Revision: 43874

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43874

  Log:
    * gc.c (gc_stat): add new information heap_eden_page_length and
      heap_tomb_page_length.
    * test/ruby/test_gc.rb: fix to use GC.stat[:heap_eden_page_length]
      instead of GC.stat[:heap_length].
      This test expects `heap_eden_page_length' (used pages size).

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
    trunk/test/ruby/test_gc.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43873)
+++ ChangeLog	(revision 43874)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Nov 27 15:05:59 2013  Koichi Sasada  <ko1@a...>
+
+	* gc.c (gc_stat): add new information heap_eden_page_length and
+	  heap_tomb_page_length.
+
+	* test/ruby/test_gc.rb: fix to use GC.stat[:heap_eden_page_length]
+	  instead of GC.stat[:heap_length].
+	  This test expects `heap_eden_page_length' (used pages size).
+
 Wed Nov 27 15:02:53 2013  Aman Gupta <ruby@t...>
 
 	* test/ruby/test_eval.rb (class TestEval): Use assert_same instead of
Index: gc.c
===================================================================
--- gc.c	(revision 43873)
+++ gc.c	(revision 43874)
@@ -2742,6 +2742,11 @@ gc_page_sweep(rb_objspace_t *objspace, r https://github.com/ruby/ruby/blob/trunk/gc.c#L2742
     heap_pages_final_slots += final_slots;
     sweep_page->final_slots = final_slots;
 
+    if (1) fprintf(stderr, "gc_page_sweep(%d): freed?: %d, limt: %d, freed_slots: %d, empty_slots: %d, final_slots: %d\n",
+		   (int)rb_gc_count(),
+		   final_slots + freed_slots + empty_slots == sweep_page->limit,
+		   (int)sweep_page->limit, (int)freed_slots, (int)empty_slots, final_slots);
+
     if (heap_pages_deferred_final && !finalizing) {
         rb_thread_t *th = GET_THREAD();
         if (th) {
@@ -5064,6 +5069,7 @@ gc_stat(int argc, VALUE *argv, VALUE sel https://github.com/ruby/ruby/blob/trunk/gc.c#L5069
     static VALUE sym_count;
     static VALUE sym_heap_used, sym_heap_length, sym_heap_increment;
     static VALUE sym_heap_live_slot, sym_heap_free_slot, sym_heap_final_slot, sym_heap_swept_slot;
+    static VALUE sym_heap_eden_page_length, sym_heap_tomb_page_length;
     static VALUE sym_total_allocated_object, sym_total_freed_object;
     static VALUE sym_malloc_increase, sym_malloc_limit;
 #if USE_RGENGC
@@ -5090,6 +5096,8 @@ gc_stat(int argc, VALUE *argv, VALUE sel https://github.com/ruby/ruby/blob/trunk/gc.c#L5096
 	S(heap_free_slot);
 	S(heap_final_slot);
 	S(heap_swept_slot);
+	S(heap_eden_page_length);
+	S(heap_tomb_page_length);
 	S(total_allocated_object);
 	S(total_freed_object);
 	S(malloc_increase);
@@ -5139,6 +5147,8 @@ gc_stat(int argc, VALUE *argv, VALUE sel https://github.com/ruby/ruby/blob/trunk/gc.c#L5147
     SET(heap_free_slot, objspace_free_slot(objspace));
     SET(heap_final_slot, heap_pages_final_slots);
     SET(heap_swept_slot, heap_pages_swept_slots);
+    SET(heap_eden_page_length, heap_eden->page_length);
+    SET(heap_tomb_page_length, heap_tomb->page_length);
     SET(total_allocated_object, objspace->profile.total_allocated_object_num);
     SET(total_freed_object, objspace->profile.total_freed_object_num);
     SET(malloc_increase, malloc_increase);
Index: test/ruby/test_gc.rb
===================================================================
--- test/ruby/test_gc.rb	(revision 43873)
+++ test/ruby/test_gc.rb	(revision 43874)
@@ -200,15 +200,16 @@ class TestGc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_gc.rb#L200
 
   def test_expand_heap
     assert_separately %w[--disable-gem], __FILE__, __LINE__, <<-'eom'
-    base_length = GC.stat[:heap_length]
-    (base_length * 500).times{ 'a' }
     GC.start
-    assert_equal base_length, GC.stat[:heap_length], "invalid heap expanding"
+    base_length = GC.stat[:heap_eden_page_length]
+    (base_length * 500).times{ 'a'; nil }
+    GC.start
+    assert_equal base_length, GC.stat[:heap_eden_page_length], "invalid heap expanding"
 
     a = []
-    (base_length * 500).times{ a << 'a' }
+    (base_length * 500).times{ a << 'a'; nil }
     GC.start
-    assert base_length < GC.stat[:heap_length]
+    assert base_length < GC.stat[:heap_eden_page_length]
     eom
   end
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]