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

ruby-changes:29525

From: nagachika <ko1@a...>
Date: Sun, 23 Jun 2013 00:33:09 +0900 (JST)
Subject: [ruby-changes:29525] nagachika:r41577 (ruby_2_0_0): merge revision(s) 41325: [Backport #8554]

nagachika	2013-06-23 00:32:54 +0900 (Sun, 23 Jun 2013)

  New Revision: 41577

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

  Log:
    merge revision(s) 41325: [Backport #8554]
    
    * 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:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/gc.c
    branches/ruby_2_0_0/version.h

Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 41576)
+++ ruby_2_0_0/ChangeLog	(revision 41577)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Sun Jun 23 00:09:12 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 23 00:03:18 2013  Charlie Somerville  <charliesome@r...>
 
 	* ext/etc/etc.c (etc_getpwnam): use PRIsVALUE in format string instead
Index: ruby_2_0_0/gc.c
===================================================================
--- ruby_2_0_0/gc.c	(revision 41576)
+++ ruby_2_0_0/gc.c	(revision 41577)
@@ -209,6 +209,7 @@ typedef struct rb_objspace { https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/gc.c#L209
     struct {
 	size_t limit;
 	size_t increase;
+	size_t increase2;
 #if CALC_EXACT_MALLOC_SIZE
 	size_t allocated_size;
 	size_t allocations;
@@ -271,6 +272,7 @@ int *ruby_initial_gc_stress_ptr = &rb_ob https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/gc.c#L272
 #endif
 #define malloc_limit		objspace->malloc_params.limit
 #define malloc_increase 	objspace->malloc_params.increase
+#define malloc_increase2 	objspace->malloc_params.increase2
 #define heaps			objspace->heap.ptr
 #define heaps_length		objspace->heap.length
 #define heaps_used		objspace->heap.used
@@ -1976,6 +1978,8 @@ before_gc_sweep(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/gc.c#L1978
     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());
@@ -1994,6 +1998,9 @@ after_gc_sweep(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/gc.c#L1998
     }
 
     inc = ATOMIC_SIZE_EXCHANGE(malloc_increase, 0);
+    inc += malloc_increase2;
+    malloc_increase2 = 0;
+
     if (inc > malloc_limit) {
 	malloc_limit +=
 	  (size_t)((inc - malloc_limit) * (double)objspace->heap.marked_num / (heaps_used * HEAP_OBJ_LIMIT));
@@ -3479,8 +3486,9 @@ vm_malloc_prepare(rb_objspace_t *objspac https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/gc.c#L3486
     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);
     }
 
@@ -3490,8 +3498,6 @@ vm_malloc_prepare(rb_objspace_t *objspac https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/gc.c#L3498
 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);
@@ -4077,7 +4083,7 @@ gc_prof_set_malloc_info(rb_objspace_t *o https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/gc.c#L4083
     if (objspace->profile.run) {
         gc_profile_record *record = &objspace->profile.record[objspace->profile.count];
         if (record) {
-            record->allocate_increase = malloc_increase;
+            record->allocate_increase = malloc_increase + malloc_increase2;
             record->allocate_limit = malloc_limit;
         }
     }
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 41576)
+++ ruby_2_0_0/version.h	(revision 41577)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2013-06-23"
-#define RUBY_PATCHLEVEL 237
+#define RUBY_PATCHLEVEL 238
 
 #define RUBY_RELEASE_YEAR 2013
 #define RUBY_RELEASE_MONTH 6

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

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