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

ruby-changes:4795

From: ko1@a...
Date: Mon, 5 May 2008 02:25:54 +0900 (JST)
Subject: [ruby-changes:4795] akr - Ruby:r16289 (trunk): * gc.c (set_heaps_increment): fix memory allocation strategy by

akr	2008-05-05 02:25:38 +0900 (Mon, 05 May 2008)

  New Revision: 16289

  Modified files:
    trunk/ChangeLog
    trunk/gc.c

  Log:
    * gc.c (set_heaps_increment): fix memory allocation strategy by
      determining heaps_inc from heaps_used, not objects_delta.
      (struct rb_objspace): delta removed.  change increment, length and
      used to long for LP64.
      (objects_delta): removed.
      (allocate_heaps): add next_heaps_length argument.
      (init_heap): renamed from add_heap.
      (garbage_collect): use heaps_increment in dont_gc.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16289&r2=16288&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/gc.c?r1=16289&r2=16288&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 16288)
+++ ChangeLog	(revision 16289)
@@ -1,3 +1,14 @@
+Mon May  5 02:10:23 2008  Tanaka Akira  <akr@f...>
+
+	* gc.c (set_heaps_increment): fix memory allocation strategy by
+	  determining heaps_inc from heaps_used, not objects_delta.
+	  (struct rb_objspace): delta removed.  change increment, length and
+	  used to long for LP64.
+	  (objects_delta): removed.
+	  (allocate_heaps): add next_heaps_length argument.
+	  (init_heap): renamed from add_heap.
+	  (garbage_collect): use heaps_increment in dont_gc.
+
 Sun May  4 21:09:32 2008  Tanaka Akira  <akr@f...>
 
 	* lib/getoptlong.rb: use $stderr instead of $deferr.
Index: gc.c
===================================================================
--- gc.c	(revision 16288)
+++ gc.c	(revision 16289)
@@ -149,11 +149,10 @@
 	unsigned long increase;
     } params;
     struct {
-	int delta;
-	int increment;
+	long increment;
 	struct heaps_slot *ptr;
-	int length;
-	int used;
+	long length;
+	long used;
 	RVALUE *freelist;
 	RVALUE *range[2];
 	RVALUE *freed;
@@ -190,7 +189,6 @@
 #define freelist		objspace->heap.freelist
 #define lomem			objspace->heap.range[0]
 #define himem			objspace->heap.range[1]
-#define objects_delta		objspace->heap.delta
 #define heaps_inc		objspace->heap.increment
 #define heaps_freed		objspace->heap.freed
 #define dont_gc 		objspace->flags.dont_gc
@@ -209,7 +207,6 @@
     rb_objspace_t *objspace = malloc(sizeof(rb_objspace_t));
     memset(objspace, 0, sizeof(*objspace));
     malloc_limit = GC_MALLOC_LIMIT;
-    objects_delta = HEAP_MIN_SLOTS;
 
     return objspace;
 }
@@ -520,12 +517,12 @@
 
 
 static void
-allocate_heaps(rb_objspace_t *objspace)
+allocate_heaps(rb_objspace_t *objspace, int next_heaps_length)
 {
     struct heaps_slot *p;
     int length;
 
-    heaps_length += objects_delta / HEAP_OBJ_LIMIT;
+    heaps_length = next_heaps_length;
     length = heaps_length*sizeof(struct heaps_slot);
     RUBY_CRITICAL(
 		  if (heaps_used > 0) {
@@ -597,15 +594,14 @@
 }
 
 static void
-add_heap(rb_objspace_t *objspace)
+init_heap(rb_objspace_t *objspace)
 {
     int add, i;
 
-    add = objects_delta / HEAP_OBJ_LIMIT;
-    objects_delta *= 1.8;
+    add = HEAP_MIN_SLOTS / HEAP_OBJ_LIMIT;
 
     if ((heaps_used + add) > heaps_length) {
-    	allocate_heaps(objspace);
+    	allocate_heaps(objspace, heaps_used + add);
     }
 
     for (i = 0; i < add; i++) {
@@ -618,11 +614,10 @@
 static void
 set_heaps_increment(rb_objspace_t *objspace)
 {
-    heaps_inc += objects_delta / HEAP_OBJ_LIMIT;
-    objects_delta *= 1.8;
+    heaps_inc = heaps_used * 1.8 - heaps_used;
 
     if ((heaps_used + heaps_inc) > heaps_length) {
-	allocate_heaps(objspace);
+	allocate_heaps(objspace, heaps_used + heaps_inc);
     }
 }
 
@@ -1351,9 +1346,6 @@
 	    free(last);
 	}
     }
-    if (i != j)	{
-	objects_delta = heaps_used * HEAP_OBJ_LIMIT;
-    }
 }
 
 void rb_gc_abort_threads(void);
@@ -1669,7 +1661,10 @@
 
     if (dont_gc || during_gc) {
 	if (!freelist) {
-	    add_heap(objspace);
+            if (!heaps_increment(objspace)) {
+                set_heaps_increment(objspace);
+                heaps_increment(objspace);
+            }
 	}
 	return Qtrue;
     }
@@ -1864,7 +1859,7 @@
     if (!rb_gc_stack_start) {
 	Init_stack(0);
     }
-    add_heap(&rb_objspace);
+    init_heap(&rb_objspace);
 }
 
 static VALUE

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

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