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

ruby-changes:31479

From: tarui <ko1@a...>
Date: Wed, 6 Nov 2013 21:36:39 +0900 (JST)
Subject: [ruby-changes:31479] tarui:r43558 (trunk): * gc.c (gc_before_sweep): Change algorithm of malloc_limit to

tarui	2013-11-06 21:36:34 +0900 (Wed, 06 Nov 2013)

  New Revision: 43558

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

  Log:
    * gc.c (gc_before_sweep): Change algorithm of malloc_limit to
      conservative for closing to memory consumption of ruby 2.0.
    
    * gc.c (GC_MALLOC_LIMIT, GC_MALLOC_LIMIT_GROWTH_FACTOR):
      Adjust parameters for new algorithm.
    
    Example: make gcbench-rdoc on a pc
                                  time       maxrss
    2.0.0p343             285.27     281853952
    trunk before patch    207.19     690405376
    trunk after patch     211.59     312500224

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43557)
+++ ChangeLog	(revision 43558)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Nov  6 21:30:55 2013  Masaya Tarui  <tarui@r...>
+
+	* gc.c (gc_before_sweep): Change algorithm of malloc_limit to
+	  conservative for closing to memory consumption of ruby 2.0.
+
+	* gc.c (GC_MALLOC_LIMIT, GC_MALLOC_LIMIT_GROWTH_FACTOR):
+	  Adjust parameters for new algorithm.
+
 Wed Nov  6 21:16:51 2013  Masaki Matsushita  <glass.saga@g...>
 
 	* array.c (rb_ary_shift_m): use RARRAY_PTR_USE() without WB because
Index: gc.c
===================================================================
--- gc.c	(revision 43557)
+++ gc.c	(revision 43558)
@@ -91,23 +91,23 @@ 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 (16 /* 16 MB */ * 1024 * 1024 /* 1MB */)
+#define GC_MALLOC_LIMIT (8 * 1024 * 1024 /* 8MB */)
 #endif
 #ifndef GC_MALLOC_LIMIT_MAX
-#define GC_MALLOC_LIMIT_MAX (384 /* 384 MB */ * 1024 * 1024 /* 1MB */)
+#define GC_MALLOC_LIMIT_MAX (384 * 1024 * 1024 /* 384MB */)
 #endif
 #ifndef GC_MALLOC_LIMIT_GROWTH_FACTOR
-#define GC_MALLOC_LIMIT_GROWTH_FACTOR 2.0
+#define GC_MALLOC_LIMIT_GROWTH_FACTOR 1.0
 #endif
 
 #ifndef GC_HEAP_OLDSPACE_MIN
-#define GC_HEAP_OLDSPACE_MIN (16 /* 16 MB */ * 1024 * 1024 /* 1MB */)
+#define GC_HEAP_OLDSPACE_MIN (16 * 1024 * 1024 /* 16MB */)
 #endif
 #ifndef GC_HEAP_OLDSPACE_GROWTH_FACTOR
 #define GC_HEAP_OLDSPACE_GROWTH_FACTOR 1.8
 #endif
 #ifndef GC_HEAP_OLDSPACE_MAX
-#define GC_HEAP_OLDSPACE_MAX (384 /* 384 MB */ * 1024 * 1024 /* 1MB */)
+#define GC_HEAP_OLDSPACE_MAX (384 * 1024 * 1024 /* 384MB */)
 #endif
 
 typedef struct {
@@ -2812,14 +2812,14 @@ gc_before_sweep(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L2812
 	size_t old_limit = malloc_limit;
 
 	if (inc > malloc_limit) {
-	    malloc_limit += (size_t)(malloc_limit * (initial_malloc_limit_growth_factor - 1));
+	    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;
 	    }
 	}
 	else {
-	    malloc_limit -= (size_t)(malloc_limit * ((initial_malloc_limit_growth_factor - 1) / 10));
+	    malloc_limit = (size_t)(malloc_limit * 0.98); /* magic number */
 	    if (malloc_limit < initial_malloc_limit) {
 		malloc_limit = initial_malloc_limit;
 	    }

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

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