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

ruby-changes:31486

From: ko1 <ko1@a...>
Date: Thu, 7 Nov 2013 19:45:11 +0900 (JST)
Subject: [ruby-changes:31486] ko1:r43565 (trunk): * gc.c: modify malloc_limit strategy.

ko1	2013-11-07 19:45:01 +0900 (Thu, 07 Nov 2013)

  New Revision: 43565

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

  Log:
    * gc.c: modify malloc_limit strategy.
      * fix default vaues:
        GC_MALLOC_LIMIT_GROWTH_FACTOR
        GC_MALLOC_LIMIT: 8MB -> 16MB
        GC_MALLOC_LIMIT_MAX: 384MB -> 32MB
      * algorithm of malloc_limit increment.
        if (malloc_increase < malloc_limit) {
          next_malloc_limit = malloc_limit * factor
          if (malloc_limit > malloc_limit_max) {
            malloc_limit = malloc_increase
          }
        }
        This algorithm change malloc_limit from
        16MB -> 32MB slowly.
        If malloc_limit exceeds malloc_limit_max, then
        increase with malloc_increase.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43564)
+++ ChangeLog	(revision 43565)
@@ -1,3 +1,24 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Nov  7 19:36:09 2013  Koichi Sasada  <ko1@a...>
+
+	* gc.c: modify malloc_limit strategy.
+
+	  * fix default vaues:
+	    GC_MALLOC_LIMIT_GROWTH_FACTOR
+	    GC_MALLOC_LIMIT: 8MB -> 16MB
+	    GC_MALLOC_LIMIT_MAX: 384MB -> 32MB
+
+	  * algorithm of malloc_limit increment.
+	    if (malloc_increase < malloc_limit) {
+	      next_malloc_limit = malloc_limit * factor
+	      if (malloc_limit > malloc_limit_max) {
+	        malloc_limit = malloc_increase
+	      }
+	    }
+	    This algorithm change malloc_limit from
+	    16MB -> 32MB slowly.
+	    If malloc_limit exceeds malloc_limit_max, then
+	    increase with malloc_increase.
+
 Thu Nov  7 11:06:05 2013  Masaki Matsushita  <glass.saga@g...>
 
 	* array.c (rb_ary_shuffle_bang): use RARRAY_PTR_USE() without WB
Index: gc.c
===================================================================
--- gc.c	(revision 43564)
+++ gc.c	(revision 43565)
@@ -91,13 +91,13 @@ rb_gc_guarded_ptr(volatile VALUE *ptr) https://github.com/ruby/ruby/blob/trunk/gc.c#L91
 #endif
 
 #ifndef GC_MALLOC_LIMIT
-#define GC_MALLOC_LIMIT (8 * 1024 * 1024 /* 8MB */)
+#define GC_MALLOC_LIMIT (16 * 1024 * 1024 /* 16MB */)
 #endif
 #ifndef GC_MALLOC_LIMIT_MAX
-#define GC_MALLOC_LIMIT_MAX (384 * 1024 * 1024 /* 384MB */)
+#define GC_MALLOC_LIMIT_MAX (32 * 1024 * 1024 /* 32MB */)
 #endif
 #ifndef GC_MALLOC_LIMIT_GROWTH_FACTOR
-#define GC_MALLOC_LIMIT_GROWTH_FACTOR 1.0
+#define GC_MALLOC_LIMIT_GROWTH_FACTOR 1.4
 #endif
 
 #ifndef GC_HEAP_OLDSPACE_MIN
@@ -2807,6 +2807,8 @@ gc_before_sweep(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L2807
     gc_prof_set_malloc_info(objspace);
 
     /* reset malloc info */
+    if (0) fprintf(stderr, "%d\t%d\t%d\n", (int)rb_gc_count(), (int)malloc_increase, (int)malloc_limit);
+
     {
 	size_t inc = ATOMIC_SIZE_EXCHANGE(malloc_increase, 0);
 	size_t old_limit = malloc_limit;
@@ -2815,7 +2817,7 @@ gc_before_sweep(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L2817
 	    malloc_limit = (size_t)(inc * initial_malloc_limit_growth_factor);
 	    if (initial_malloc_limit_max > 0 && /* ignore max-check if 0 */
 		malloc_limit > initial_malloc_limit_max) {
-		malloc_limit = initial_malloc_limit_max;
+		malloc_limit = inc;
 	    }
 	}
 	else {

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

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