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

ruby-changes:31320

From: tmm1 <ko1@a...>
Date: Thu, 24 Oct 2013 00:05:31 +0900 (JST)
Subject: [ruby-changes:31320] tmm1:r43399 (trunk): * gc.c: Rename free_min to min_free_slots and free_min_page to max_free_slots. The algorithm for heap growth is:

tmm1	2013-10-24 00:05:22 +0900 (Thu, 24 Oct 2013)

  New Revision: 43399

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

  Log:
    * gc.c: Rename free_min to min_free_slots and free_min_page to max_free_slots. The algorithm for heap growth is:
    
        if (swept_slots < min_free_slots) pages++
        if (swept_slots > max_free_slots) pages--

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43398)
+++ ChangeLog	(revision 43399)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Oct 23 23:48:28 2013  Aman Gupta <ruby@t...>
+
+	* gc.c: Rename free_min to min_free_slots and free_min_page to
+	  max_free_slots. The algorithm for heap growth is:
+	    if (swept_slots < min_free_slots) pages++
+	    if (swept_slots > max_free_slots) pages--
+
 Wed Oct 23 22:51:03 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* win32/Makefile.sub (config.h): VC 2013 supports C99 mathematics
Index: gc.c
===================================================================
--- gc.c	(revision 43398)
+++ gc.c	(revision 43399)
@@ -77,8 +77,8 @@ rb_gc_guarded_ptr(volatile VALUE *ptr) https://github.com/ruby/ruby/blob/trunk/gc.c#L77
 }
 #endif
 
-#ifndef GC_FREE_MIN
-#define GC_FREE_MIN  4096
+#ifndef GC_HEAP_MIN_FREE_SLOTS
+#define GC_HEAP_MIN_FREE_SLOTS  4096
 #endif
 #ifndef GC_HEAP_MIN_SLOTS
 #define GC_HEAP_MIN_SLOTS 10000
@@ -98,7 +98,7 @@ rb_gc_guarded_ptr(volatile VALUE *ptr) https://github.com/ruby/ruby/blob/trunk/gc.c#L98
 
 typedef struct {
     unsigned int initial_heap_min_slots;
-    unsigned int initial_free_min;
+    unsigned int initial_heap_min_free_slots;
     double initial_growth_factor;
     unsigned int initial_malloc_limit;
     unsigned int initial_malloc_limit_max;
@@ -110,7 +110,7 @@ typedef struct { https://github.com/ruby/ruby/blob/trunk/gc.c#L110
 
 static ruby_gc_params_t initial_params = {
     GC_HEAP_MIN_SLOTS,
-    GC_FREE_MIN,
+    GC_HEAP_MIN_FREE_SLOTS,
     GC_HEAP_GROWTH_FACTOR,
     GC_MALLOC_LIMIT,
     GC_MALLOC_LIMIT_MAX,
@@ -351,8 +351,8 @@ typedef struct rb_objspace { https://github.com/ruby/ruby/blob/trunk/gc.c#L351
 	size_t swept_num;
 	size_t increment;
 
-	size_t free_min;
-	size_t free_min_page;
+	size_t min_free_slots;
+	size_t max_free_slots;
 
 	/* final */
 	size_t final_num;
@@ -515,8 +515,8 @@ VALUE *ruby_initial_gc_stress_ptr = &rb_ https://github.com/ruby/ruby/blob/trunk/gc.c#L515
 #define heap_pages_himem	objspace->heap_pages.range[1]
 #define heap_pages_swept_num	objspace->heap_pages.swept_num
 #define heap_pages_increment	objspace->heap_pages.increment
-#define heap_pages_free_min		objspace->heap_pages.free_min
-#define heap_pages_free_min_page	objspace->heap_pages.free_min_page
+#define heap_pages_min_free_slots	objspace->heap_pages.min_free_slots
+#define heap_pages_max_free_slots	objspace->heap_pages.max_free_slots
 #define heap_pages_final_num		objspace->heap_pages.final_num
 #define heap_pages_deferred_final	objspace->heap_pages.deferred_final
 #define heap_eden               (&objspace->eden_heap)
@@ -534,7 +534,7 @@ VALUE *ruby_initial_gc_stress_ptr = &rb_ https://github.com/ruby/ruby/blob/trunk/gc.c#L534
 #define initial_malloc_limit_max           initial_params.initial_malloc_limit_max
 #define initial_malloc_limit_growth_factor initial_params.initial_malloc_limit_growth_factor
 #define initial_heap_min_slots	           initial_params.initial_heap_min_slots
-#define initial_free_min	           initial_params.initial_free_min
+#define initial_heap_min_free_slots	   initial_params.initial_heap_min_free_slots
 #define initial_growth_factor	           initial_params.initial_growth_factor
 
 #define is_lazy_sweeping(heap) ((heap)->sweep_pages != 0)
@@ -827,9 +827,9 @@ heap_pages_free_unused_pages(rb_objspace https://github.com/ruby/ruby/blob/trunk/gc.c#L827
 	struct heap_page *page = heap_pages_sorted[i];
 
 	if (page->heap == heap_tomb && page->final_num == 0) {
-	    if (heap_pages_swept_num - page->limit > heap_pages_free_min_page) {
-		if (0) fprintf(stderr, "heap_pages_free_unused_pages: %d free page %p, heap_pages_swept_num: %d, heap_pages_do_heap_free: %d\n",
-			       (int)i, page, (int)heap_pages_swept_num, (int)heap_pages_free_min_page);
+	    if (heap_pages_swept_num - page->limit > heap_pages_max_free_slots) {
+		if (0) fprintf(stderr, "heap_pages_free_unused_pages: %d free page %p, heap_pages_swept_num: %d, heap_pages_max_free_slots: %d\n",
+			       (int)i, page, (int)heap_pages_swept_num, (int)heap_pages_max_free_slots);
 		heap_pages_swept_num -= page->limit;
 		heap_unlink_page(objspace, heap_tomb, page);
 		heap_page_free(objspace, page);
@@ -2498,16 +2498,16 @@ gc_before_sweep(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L2498
     heap_pages_swept_num = 0;
     total_limit_num = objspace_limit_num(objspace);
 
-    heap_pages_free_min = (size_t)(total_limit_num * 0.20);
-    if (heap_pages_free_min < initial_free_min) {
-	heap_pages_free_min = initial_free_min;
-    }
-    heap_pages_free_min_page = (size_t)(total_limit_num * 0.80);
-    if (heap_pages_free_min_page < initial_heap_min_slots) {
-	heap_pages_free_min_page = initial_heap_min_slots;
+    heap_pages_min_free_slots = (size_t)(total_limit_num * 0.20);
+    if (heap_pages_min_free_slots < initial_heap_min_free_slots) {
+	heap_pages_min_free_slots = initial_heap_min_free_slots;
+    }
+    heap_pages_max_free_slots = (size_t)(total_limit_num * 0.80);
+    if (heap_pages_max_free_slots < initial_heap_min_slots) {
+	heap_pages_max_free_slots = initial_heap_min_slots;
     }
-    if (0) fprintf(stderr, "heap_pages_free_min: %d, heap_pages_free_min_page: %d\n",
-		   (int)heap_pages_free_min, (int)heap_pages_free_min_page);
+    if (0) fprintf(stderr, "heap_pages_min_free_slots: %d, heap_pages_max_free_slots: %d\n",
+		   (int)heap_pages_min_free_slots, (int)heap_pages_max_free_slots);
 
     heap = heap_eden;
     gc_before_heap_sweep(objspace, heap);
@@ -2551,10 +2551,10 @@ gc_after_sweep(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L2551
 {
     rb_heap_t *heap = heap_eden;
 
-    rgengc_report(1, objspace, "after_gc_sweep: heap->limit: %d, heap->swept_num: %d, free_min: %d\n",
-		  (int)heap->limit, (int)heap_pages_swept_num, (int)heap_pages_free_min);
+    rgengc_report(1, objspace, "after_gc_sweep: heap->limit: %d, heap->swept_num: %d, min_free_slots: %d\n",
+		  (int)heap->limit, (int)heap_pages_swept_num, (int)heap_pages_min_free_slots);
 
-    if (heap_pages_swept_num < heap_pages_free_min) {
+    if (heap_pages_swept_num < heap_pages_min_free_slots) {
 	heap_set_increment(objspace);
 	heap_increment(objspace, heap);
 
@@ -4810,7 +4810,7 @@ rb_gc_set_params(void) https://github.com/ruby/ruby/blob/trunk/gc.c#L4810
 {
     if (rb_safe_level() > 0) return;
 
-    get_envparam_int   ("RUBY_FREE_MIN", &initial_free_min, 0);
+    get_envparam_int   ("RUBY_FREE_MIN", &initial_heap_min_free_slots, 0);
 
     get_envparam_double("RUBY_HEAP_SLOTS_GROWTH_FACTOR", &initial_growth_factor, 1.0);
     if (get_envparam_int("RUBY_HEAP_MIN_SLOTS", &initial_heap_min_slots, 0)) {

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

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