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

ruby-changes:31059

From: tmm1 <ko1@a...>
Date: Fri, 4 Oct 2013 19:05:45 +0900 (JST)
Subject: [ruby-changes:31059] tmm1:r43138 (trunk): gc.c: add rb_objspace.limit

tmm1	2013-10-04 19:05:37 +0900 (Fri, 04 Oct 2013)

  New Revision: 43138

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

  Log:
    gc.c: add rb_objspace.limit
    
    * gc.c: add rb_objspace.limit to keep accurate count of total heap
      slots [ruby-core:57633] [Bug #8983]

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43137)
+++ ChangeLog	(revision 43138)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Oct  4 18:53:42 2013  Aman Gupta <ruby@t...>
+
+	* gc.c: add rb_objspace.limit to keep accurate count of total heap
+	  slots [ruby-core:57633] [Bug #8983]
+
 Fri Oct  4 09:32:33 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/csv.rb (CSV.foreach): support enumerator.  based on a patch by
Index: gc.c
===================================================================
--- gc.c	(revision 43137)
+++ gc.c	(revision 43138)
@@ -333,6 +333,7 @@ typedef struct rb_objspace { https://github.com/ruby/ruby/blob/trunk/gc.c#L333
 	struct heap_slot **sorted;
 	size_t length;
 	size_t used;
+	size_t limit;
 	RVALUE *range[2];
 	size_t free_num;
 	size_t free_min;
@@ -494,6 +495,7 @@ VALUE *ruby_initial_gc_stress_ptr = &rb_ https://github.com/ruby/ruby/blob/trunk/gc.c#L495
 #define heap_slots		objspace->heap.slots
 #define heap_length		objspace->heap.length
 #define heap_used		objspace->heap.used
+#define heap_limit		objspace->heap.limit
 #define lomem			objspace->heap.range[0]
 #define himem			objspace->heap.range[1]
 #define heap_inc		objspace->heap.increment
@@ -706,6 +708,7 @@ rb_objspace_free(rb_objspace_t *objspace https://github.com/ruby/ruby/blob/trunk/gc.c#L708
 	}
 	free(objspace->heap.sorted);
 	heap_used = 0;
+	heap_limit = 0;
 	heap_slots = 0;
     }
     free_stack_chunks(&objspace->mark_stack);
@@ -824,6 +827,7 @@ heap_assign_slot(rb_objspace_t *objspace https://github.com/ruby/ruby/blob/trunk/gc.c#L827
     if (lomem == 0 || lomem > start) lomem = start;
     if (himem < end) himem = end;
     heap_used++;
+    heap_limit += limit;
 
     for (p = start; p != end; p++) {
 	rgengc_report(3, objspace, "assign_heap_slot: %p is added to freelist\n");
@@ -2344,6 +2348,7 @@ gc_slot_sweep(rb_objspace_t *objspace, s https://github.com/ruby/ruby/blob/trunk/gc.c#L2348
 	    RDATA(pp)->dmark = (void (*)(void *))(VALUE)sweep_slot;
             pp->as.free.flags |= FL_SINGLETON; /* freeing page mark */
         }
+        heap_limit -= sweep_slot->limit;
         sweep_slot->limit = final_num;
         unlink_heap_slot(objspace, sweep_slot);
     }
@@ -2377,8 +2382,8 @@ gc_before_sweep(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L2382
 {
     rgengc_report(1, objspace, "gc_before_sweep\n");
 
-    objspace->heap.do_heap_free = (size_t)((heap_used * HEAP_OBJ_LIMIT) * 0.65);
-    objspace->heap.free_min = (size_t)((heap_used * HEAP_OBJ_LIMIT)  * 0.2);
+    objspace->heap.do_heap_free = (size_t)(heap_limit * 0.65);
+    objspace->heap.free_min = (size_t)(heap_limit * 0.2);
     if (objspace->heap.free_min < initial_free_min) {
 	objspace->heap.free_min = initial_free_min;
 	if (objspace->heap.do_heap_free < initial_free_min) {

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

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