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

ruby-changes:33867

From: ko1 <ko1@a...>
Date: Thu, 15 May 2014 18:43:31 +0900 (JST)
Subject: [ruby-changes:33867] ko1:r45948 (trunk): * gc.c: introduce macros to remove magic number.

ko1	2014-05-15 18:43:18 +0900 (Thu, 15 May 2014)

  New Revision: 45948

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

  Log:
    * gc.c: introduce macros to remove magic number.
      GC_HEAP_FREE_SLOTS_MIN_RATIO = 0.3: guarantee minimum empty slots
                                          ratio after sweep.
      GC_HEAP_FREE_SLOTS_MAX_RATIO = 0.8: allow to free pages 0.2 (= 1-0.8)
                                          of current existing slots.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45947)
+++ ChangeLog	(revision 45948)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu May 15 18:42:49 2014  Koichi Sasada  <ko1@a...>
+
+	* gc.c: introduce macros to remove magic number.
+
+	  GC_HEAP_FREE_SLOTS_MIN_RATIO = 0.3: guarantee minimum empty slots
+	                                      ratio after sweep.
+	  GC_HEAP_FREE_SLOTS_MAX_RATIO = 0.8: allow to free pages 0.2 (= 1-0.8)
+	                                      of current existing slots.
+
 Thu May 15 17:32:51 2014  Hiroshi Shirosaki  <h.shirosaki@g...>
 
 	* thread_win32.c (rb_w32_stack_overflow_handler): use Structured
Index: gc.c
===================================================================
--- gc.c	(revision 45947)
+++ gc.c	(revision 45948)
@@ -116,6 +116,13 @@ rb_gc_guarded_ptr_val(volatile VALUE *pt https://github.com/ruby/ruby/blob/trunk/gc.c#L116
 #define GC_HEAP_OLDOBJECT_LIMIT_FACTOR 2.0
 #endif
 
+#ifndef GC_HEAP_FREE_SLOTS_MIN_RATIO
+#define GC_HEAP_FREE_SLOTS_MIN_RATIO 0.3
+#endif
+#ifndef GC_HEAP_FREE_SLOTS_MAX_RATIO
+#define GC_HEAP_FREE_SLOTS_MAX_RATIO 0.8
+#endif
+
 #ifndef GC_MALLOC_LIMIT_MIN
 #define GC_MALLOC_LIMIT_MIN (16 * 1024 * 1024 /* 16MB */)
 #endif
@@ -2902,11 +2909,11 @@ gc_before_sweep(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L2909
     heap_pages_swept_slots = 0;
     total_limit_slot = objspace_total_slot(objspace);
 
-    heap_pages_min_free_slots = (size_t)(total_limit_slot * 0.30);
+    heap_pages_min_free_slots = (size_t)(total_limit_slot * GC_HEAP_FREE_SLOTS_MIN_RATIO);
     if (heap_pages_min_free_slots < gc_params.heap_free_slots) {
 	heap_pages_min_free_slots = gc_params.heap_free_slots;
     }
-    heap_pages_max_free_slots = (size_t)(total_limit_slot * 0.80);
+    heap_pages_max_free_slots = (size_t)(total_limit_slot * GC_HEAP_FREE_SLOTS_MAX_RATIO);
     if (heap_pages_max_free_slots < gc_params.heap_init_slots) {
 	heap_pages_max_free_slots = gc_params.heap_init_slots;
     }

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

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