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

ruby-changes:29273

From: tarui <ko1@a...>
Date: Sun, 16 Jun 2013 05:53:21 +0900 (JST)
Subject: [ruby-changes:29273] tarui:r41325 (trunk): * gc.c: Fixup around GC by MALLOC.

tarui	2013-06-16 05:53:01 +0900 (Sun, 16 Jun 2013)

  New Revision: 41325

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

  Log:
    * gc.c: Fixup around GC by MALLOC. 
      Add allocate size to malloc_increase before GC 
      for updating limit in after_gc_sweep.
      Reset malloc_increase into garbage_collect() 
      for preventing GC again soon.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41324)
+++ ChangeLog	(revision 41325)
@@ -1,6 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Jun 16 05:51:51 2013  Masaya Tarui  <tarui@r...>
+
+	* gc.c: Fixup around GC by MALLOC. 
+	  Add allocate size to malloc_increase before GC 
+	  for updating limit in after_gc_sweep.
+	  Reset malloc_increase into garbage_collect() 
+	  for preventing GC again soon.
+
 Sun Jun 16 05:15:36 2013  Masaya Tarui  <tarui@r...>
 
-	* gc.c : Add some colums to more detail profile.
+	* gc.c: Add some colums to more detail profile.
 	  new colums: Allocated size, Prepare Time, Removing Objects, Empty Objects
 
 Sun Jun 16 02:04:40 2013  Masaya Tarui  <tarui@r...>
Index: gc.c
===================================================================
--- gc.c	(revision 41324)
+++ gc.c	(revision 41325)
@@ -287,6 +287,7 @@ typedef struct rb_objspace { https://github.com/ruby/ruby/blob/trunk/gc.c#L287
     struct {
 	size_t limit;
 	size_t increase;
+	size_t increase2;
 #if CALC_EXACT_MALLOC_SIZE
 	size_t allocated_size;
 	size_t allocations;
@@ -392,6 +393,7 @@ int *ruby_initial_gc_stress_ptr = &rb_ob https://github.com/ruby/ruby/blob/trunk/gc.c#L393
 #endif
 #define malloc_limit		objspace->malloc_params.limit
 #define malloc_increase 	objspace->malloc_params.increase
+#define malloc_increase2 	objspace->malloc_params.increase2
 #define malloc_allocated_size 	objspace->malloc_params.allocated_size
 #define heaps			objspace->heap.ptr
 #define heaps_length		objspace->heap.length
@@ -2340,6 +2342,8 @@ before_gc_sweep(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L2342
     objspace->heap.free_num = 0;
     objspace->heap.free_slots = NULL;
 
+    malloc_increase2 += ATOMIC_SIZE_EXCHANGE(malloc_increase,0);
+
     /* sweep unlinked method entries */
     if (GET_VM()->unlinked_method_entry_list) {
 	rb_sweep_method_entry(GET_VM());
@@ -2368,6 +2372,8 @@ after_gc_sweep(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L2372
     }
 
     inc = ATOMIC_SIZE_EXCHANGE(malloc_increase, 0);
+    inc += malloc_increase2;
+    malloc_increase2 = 0;
 
     if (inc > malloc_limit) {
 	malloc_limit +=
@@ -4405,8 +4411,9 @@ vm_malloc_prepare(rb_objspace_t *objspac https://github.com/ruby/ruby/blob/trunk/gc.c#L4411
     size += sizeof(size_t);
 #endif
 
+    ATOMIC_SIZE_ADD(malloc_increase, size);
     if ((ruby_gc_stress && !ruby_disable_gc_stress) ||
-	(malloc_increase+size) > malloc_limit) {
+	malloc_increase > malloc_limit) {
 	garbage_collect_with_gvl(objspace, 0, 0, GPR_FLAG_MALLOC);
     }
 
@@ -4416,8 +4423,6 @@ vm_malloc_prepare(rb_objspace_t *objspac https://github.com/ruby/ruby/blob/trunk/gc.c#L4423
 static inline void *
 vm_malloc_fixup(rb_objspace_t *objspace, void *mem, size_t size)
 {
-    ATOMIC_SIZE_ADD(malloc_increase, size);
-
 #if CALC_EXACT_MALLOC_SIZE
     ATOMIC_SIZE_ADD(objspace->malloc_params.allocated_size, size);
     ATOMIC_SIZE_INC(objspace->malloc_params.allocations);
@@ -4964,7 +4969,7 @@ gc_prof_set_malloc_info(rb_objspace_t *o https://github.com/ruby/ruby/blob/trunk/gc.c#L4969
 #if GC_PROFILE_MORE_DETAIL
     if (objspace->profile.run) {
         gc_profile_record *record = gc_prof_record(objspace);
-	record->allocate_increase = malloc_increase;
+	record->allocate_increase = malloc_increase + malloc_increase2;
 	record->allocate_limit = malloc_limit;
 #if CALC_EXACT_MALLOC_SIZE
 	record->allocated_size = malloc_allocated_size;

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

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