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

ruby-changes:35411

From: ko1 <ko1@a...>
Date: Wed, 10 Sep 2014 11:47:13 +0900 (JST)
Subject: [ruby-changes:35411] ko1:r47493 (trunk): * gc.c (gc_stat_internal): rename `heap_used' to `heap_allocated_pages'.

ko1	2014-09-10 11:47:05 +0900 (Wed, 10 Sep 2014)

  New Revision: 47493

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

  Log:
    * gc.c (gc_stat_internal): rename `heap_used' to `heap_allocated_pages'.
      ref: [Feature #9924]
    * test/ruby/test_gc.rb: add constraints test for gc stat information.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
    trunk/test/ruby/test_gc.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47492)
+++ ChangeLog	(revision 47493)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Sep 10 11:45:40 2014  Koichi Sasada  <ko1@a...>
+
+	* gc.c (gc_stat_internal): rename `heap_used' to `heap_allocated_pages'.
+	  ref: [Feature #9924]
+
+	* test/ruby/test_gc.rb: add constraints test for gc stat information.
+
 Wed Sep 10 11:31:16 2014  Koichi Sasada  <ko1@a...>
 
 	* gc.c (gc_stat_internal): rename:
Index: gc.c
===================================================================
--- gc.c	(revision 47492)
+++ gc.c	(revision 47493)
@@ -6254,7 +6254,7 @@ size_t https://github.com/ruby/ruby/blob/trunk/gc.c#L6254
 gc_stat_internal(VALUE hash_or_sym)
 {
     static VALUE sym_count;
-    static VALUE sym_heap_used, sym_heap_sorted_length, sym_heap_allocatable_pages;
+    static VALUE sym_heap_allocated_pages, sym_heap_sorted_length, sym_heap_allocatable_pages;
     static VALUE sym_heap_available_slots, sym_heap_live_slots, sym_heap_free_slots, sym_heap_final_slots;
     static VALUE sym_heap_marked_slots, sym_heap_swept_slots;
     static VALUE sym_heap_eden_pages, sym_heap_tomb_pages;
@@ -6291,7 +6291,7 @@ gc_stat_internal(VALUE hash_or_sym) https://github.com/ruby/ruby/blob/trunk/gc.c#L6291
     if (sym_count == 0) {
 #define S(s) sym_##s = ID2SYM(rb_intern_const(#s))
 	S(count);
-	S(heap_used);
+	S(heap_allocated_pages);
 	S(heap_sorted_length);
 	S(heap_allocatable_pages);
 	S(heap_available_slots);
@@ -6340,7 +6340,7 @@ gc_stat_internal(VALUE hash_or_sym) https://github.com/ruby/ruby/blob/trunk/gc.c#L6340
     SET(count, objspace->profile.count);
 
     /* implementation dependent counters */
-    SET(heap_used, heap_allocated_pages);
+    SET(heap_allocated_pages, heap_allocated_pages);
     SET(heap_sorted_length, heap_pages_sorted_length);
     SET(heap_allocatable_pages, heap_allocatable_pages);
     SET(heap_available_slots, objspace_available_slots(objspace));
Index: test/ruby/test_gc.rb
===================================================================
--- test/ruby/test_gc.rb	(revision 47492)
+++ test/ruby/test_gc.rb	(revision 47493)
@@ -111,6 +111,19 @@ class TestGc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_gc.rb#L111
     assert_raise(ArgumentError){ GC.stat(:invalid) }
   end
 
+  def test_stat_constraints
+    stat = GC.stat
+    assert_equal stat[:total_allocated_pages], stat[:heap_allocated_pages] + stat[:total_freed_pages]
+    assert_operator stat[:heap_sorted_length], :>=, stat[:heap_allocated_pages] + stat[:heap_allocatable_pages]
+    assert_equal stat[:heap_available_slots], stat[:heap_live_slots] + stat[:heap_free_slots] + stat[:heap_final_slots]
+    assert_equal stat[:heap_live_slots], stat[:total_allocated_objects] - stat[:total_freed_objects] - stat[:heap_final_slots]
+
+    if use_rgengc?
+      assert_equal stat[:count], stat[:major_gc_count] + stat[:minor_gc_count]
+      assert_equal stat[:heap_allocated_pages], stat[:heap_eden_pages] + stat[:heap_tomb_pages]
+    end
+  end
+
   def test_latest_gc_info
     GC.start
     count = GC.stat(:heap_free_slots) + GC.stat(:heap_allocatable_pages) * GC::INTERNAL_CONSTANTS[:HEAP_OBJ_LIMIT]

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

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