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

ruby-changes:32965

From: naruse <ko1@a...>
Date: Wed, 19 Feb 2014 15:00:52 +0900 (JST)
Subject: [ruby-changes:32965] naruse:r45044 (ruby_2_1): merge revision(s) 45021, 45022, 45028: [Backport #9524]

naruse	2014-02-19 15:00:46 +0900 (Wed, 19 Feb 2014)

  New Revision: 45044

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

  Log:
    merge revision(s) 45021,45022,45028: [Backport #9524]
    
    * gc.c: introduce new environment variable
      "RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR" to control major/minor GC
      frequency.
      Do full GC when the number of old objects is more than R * N
      where R is this factor and
    
    * test/ruby/test_gc.rb: add a test.
    
    * gc.c (get_envparam_double): fix a warning message.

  Modified directories:
    branches/ruby_2_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/gc.c
    branches/ruby_2_1/test/ruby/test_gc.rb
    branches/ruby_2_1/version.h
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 45043)
+++ ruby_2_1/ChangeLog	(revision 45044)
@@ -1,3 +1,24 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Wed Feb 19 14:25:55 2014  Koichi Sasada  <ko1@a...>
+
+	* test/ruby/test_gc.rb: ignore warning messages for running with -w
+	  option such as chkbuild.
+
+Wed Feb 19 14:25:55 2014  Koichi Sasada  <ko1@a...>
+
+	* gc.c (get_envparam_double): fix a warning message.
+
+Wed Feb 19 14:25:55 2014  Koichi Sasada  <ko1@a...>
+
+	* gc.c: introduce new environment variable
+	  "RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR" to control major/minor GC
+	  frequency.
+
+	  Do full GC when the number of old objects is more than R * N
+	  where R is this factor and
+	  N is the number of old objects just after last full GC.
+
+	* test/ruby/test_gc.rb: add a test.
+
 Wed Feb 19 07:51:02 2014  Eric Hodel  <drbrain@s...>
 
 	* lib/rinda/ring.rb (Rinda::RingFinger#make_socket):  Use
Index: ruby_2_1/gc.c
===================================================================
--- ruby_2_1/gc.c	(revision 45043)
+++ ruby_2_1/gc.c	(revision 45044)
@@ -108,6 +108,9 @@ rb_gc_guarded_ptr(volatile VALUE *ptr) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/gc.c#L108
 #ifndef GC_HEAP_GROWTH_MAX_SLOTS
 #define GC_HEAP_GROWTH_MAX_SLOTS 0 /* 0 is disable */
 #endif
+#ifndef GC_HEAP_OLDOBJECT_LIMIT_FACTOR
+#define GC_HEAP_OLDOBJECT_LIMIT_FACTOR 2.0
+#endif
 
 #ifndef GC_MALLOC_LIMIT_MIN
 #define GC_MALLOC_LIMIT_MIN (16 * 1024 * 1024 /* 16MB */)
@@ -134,6 +137,7 @@ typedef struct { https://github.com/ruby/ruby/blob/trunk/ruby_2_1/gc.c#L137
     unsigned int heap_free_slots;
     double growth_factor;
     unsigned int growth_max_slots;
+    double oldobject_limit_factor;
     unsigned int malloc_limit_min;
     unsigned int malloc_limit_max;
     double malloc_limit_growth_factor;
@@ -150,6 +154,7 @@ static ruby_gc_params_t gc_params = { https://github.com/ruby/ruby/blob/trunk/ruby_2_1/gc.c#L154
     GC_HEAP_INIT_SLOTS,
     GC_HEAP_GROWTH_FACTOR,
     GC_HEAP_GROWTH_MAX_SLOTS,
+    GC_HEAP_OLDOBJECT_LIMIT_FACTOR,
     GC_MALLOC_LIMIT_MIN,
     GC_MALLOC_LIMIT_MAX,
     GC_MALLOC_LIMIT_GROWTH_FACTOR,
@@ -4498,10 +4503,12 @@ gc_marks(rb_objspace_t *objspace, int fu https://github.com/ruby/ruby/blob/trunk/ruby_2_1/gc.c#L4503
 #endif
 
 	    gc_marks_body(objspace, TRUE);
-
-	    /* Do full GC if old/remembered_shady object counts is greater than counts two times at last full GC counts */
-	    objspace->rgengc.remembered_shady_object_limit = objspace->rgengc.remembered_shady_object_count * 2;
-	    objspace->rgengc.old_object_limit = objspace->rgengc.old_object_count * 2;
+	    {
+		/* See the comment about RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR */
+		const double r = gc_params.oldobject_limit_factor;
+		objspace->rgengc.remembered_shady_object_limit = objspace->rgengc.remembered_shady_object_count * r;
+		objspace->rgengc.old_object_limit = objspace->rgengc.old_object_count * r;
+	    }
 	}
 	else { /* minor GC */
 	    gc_marks_body(objspace, FALSE);
@@ -5706,6 +5713,10 @@ gc_set_initial_pages(void) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/gc.c#L5713
  *   - (next slots number) = (current slots number) * (this factor)
  * * RUBY_GC_HEAP_GROWTH_MAX_SLOTS (new from 2.1)
  *   - Allocation rate is limited to this factor.
+ * * RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR (new from 2.1.1)
+ *   - Do full GC when the number of old objects is more than R * N
+ *     where R is this factor and
+ *           N is the number of old objects just after last full GC.
  *
  *  * obsolete
  *    * RUBY_FREE_MIN       -> RUBY_GC_HEAP_FREE_SLOTS (from 2.1)
@@ -5742,6 +5753,7 @@ ruby_gc_set_params(int safe_level) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/gc.c#L5753
 
     get_envparam_double("RUBY_GC_HEAP_GROWTH_FACTOR", &gc_params.growth_factor, 1.0);
     get_envparam_int   ("RUBY_GC_HEAP_GROWTH_MAX_SLOTS", &gc_params.growth_max_slots, 0);
+    get_envparam_double("RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR", &gc_params.oldobject_limit_factor, 0.0);
 
     get_envparam_int("RUBY_GC_MALLOC_LIMIT", &gc_params.malloc_limit_min, 0);
     get_envparam_int("RUBY_GC_MALLOC_LIMIT_MAX", &gc_params.malloc_limit_max, 0);
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 45043)
+++ ruby_2_1/version.h	(revision 45044)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.1"
 #define RUBY_RELEASE_DATE "2014-02-19"
-#define RUBY_PATCHLEVEL 33
+#define RUBY_PATCHLEVEL 34
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 2
Index: ruby_2_1/test/ruby/test_gc.rb
===================================================================
--- ruby_2_1/test/ruby/test_gc.rb	(revision 45043)
+++ ruby_2_1/test/ruby/test_gc.rb	(revision 45044)
@@ -177,6 +177,16 @@ class TestGc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_gc.rb#L177
     assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_HEAP_GROWTH_FACTOR=2.0/, "")
     assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_HEAP_GROWTH_MAX_SLOTS=10000/, "[ruby-core:57928]")
 
+    env = {
+      "RUBY_GC_HEAP_INIT_SLOTS" => "100000",
+      "RUBY_GC_HEAP_FREE_SLOTS" => "10000",
+      "RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR" => "0.9",
+    }
+    assert_normal_exit("exit", "", :child_env => env)
+    assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=0\.9/, "")
+    # always full GC when RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR < 1.0
+    assert_in_out_err([env, "-e", "1000_000.times{Object.new}; p(GC.stat[:minor_gc_count] < GC.stat[:major_gc_count])"], "", ['true'], //, "")
+
     # check obsolete
     assert_in_out_err([{'RUBY_FREE_MIN' => '100'}, '-w', '-eexit'], '', [],
       /RUBY_FREE_MIN is obsolete. Use RUBY_GC_HEAP_FREE_SLOTS instead/)

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r45021-45022,45028


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

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