Skip to content

Commit 4219cf6

Browse files
committed
merge revision(s) 41325: [Backport ruby#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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@41577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 2d3482a commit 4219cf6

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Sun Jun 23 00:09:12 2013 Masaya Tarui <[email protected]>
2+
3+
* gc.c: Fixup around GC by MALLOC.
4+
Add allocate size to malloc_increase before GC
5+
for updating limit in after_gc_sweep.
6+
Reset malloc_increase into garbage_collect()
7+
for preventing GC again soon.
8+
19
Sun Jun 23 00:03:18 2013 Charlie Somerville <[email protected]>
210

311
* ext/etc/etc.c (etc_getpwnam): use PRIsVALUE in format string instead

gc.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ typedef struct rb_objspace {
209209
struct {
210210
size_t limit;
211211
size_t increase;
212+
size_t increase2;
212213
#if CALC_EXACT_MALLOC_SIZE
213214
size_t allocated_size;
214215
size_t allocations;
@@ -271,6 +272,7 @@ int *ruby_initial_gc_stress_ptr = &rb_objspace.gc_stress;
271272
#endif
272273
#define malloc_limit objspace->malloc_params.limit
273274
#define malloc_increase objspace->malloc_params.increase
275+
#define malloc_increase2 objspace->malloc_params.increase2
274276
#define heaps objspace->heap.ptr
275277
#define heaps_length objspace->heap.length
276278
#define heaps_used objspace->heap.used
@@ -1976,6 +1978,8 @@ before_gc_sweep(rb_objspace_t *objspace)
19761978
objspace->heap.free_num = 0;
19771979
objspace->heap.free_slots = NULL;
19781980

1981+
malloc_increase2 += ATOMIC_SIZE_EXCHANGE(malloc_increase,0);
1982+
19791983
/* sweep unlinked method entries */
19801984
if (GET_VM()->unlinked_method_entry_list) {
19811985
rb_sweep_method_entry(GET_VM());
@@ -1994,6 +1998,9 @@ after_gc_sweep(rb_objspace_t *objspace)
19941998
}
19951999

19962000
inc = ATOMIC_SIZE_EXCHANGE(malloc_increase, 0);
2001+
inc += malloc_increase2;
2002+
malloc_increase2 = 0;
2003+
19972004
if (inc > malloc_limit) {
19982005
malloc_limit +=
19992006
(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 *objspace, size_t size)
34793486
size += sizeof(size_t);
34803487
#endif
34813488

3489+
ATOMIC_SIZE_ADD(malloc_increase, size);
34823490
if ((ruby_gc_stress && !ruby_disable_gc_stress) ||
3483-
(malloc_increase+size) > malloc_limit) {
3491+
malloc_increase > malloc_limit) {
34843492
garbage_collect_with_gvl(objspace);
34853493
}
34863494

@@ -3490,8 +3498,6 @@ vm_malloc_prepare(rb_objspace_t *objspace, size_t size)
34903498
static inline void *
34913499
vm_malloc_fixup(rb_objspace_t *objspace, void *mem, size_t size)
34923500
{
3493-
ATOMIC_SIZE_ADD(malloc_increase, size);
3494-
34953501
#if CALC_EXACT_MALLOC_SIZE
34963502
ATOMIC_SIZE_ADD(objspace->malloc_params.allocated_size, size);
34973503
ATOMIC_SIZE_INC(objspace->malloc_params.allocations);
@@ -4077,7 +4083,7 @@ gc_prof_set_malloc_info(rb_objspace_t *objspace)
40774083
if (objspace->profile.run) {
40784084
gc_profile_record *record = &objspace->profile.record[objspace->profile.count];
40794085
if (record) {
4080-
record->allocate_increase = malloc_increase;
4086+
record->allocate_increase = malloc_increase + malloc_increase2;
40814087
record->allocate_limit = malloc_limit;
40824088
}
40834089
}

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.0.0"
22
#define RUBY_RELEASE_DATE "2013-06-23"
3-
#define RUBY_PATCHLEVEL 237
3+
#define RUBY_PATCHLEVEL 238
44

55
#define RUBY_RELEASE_YEAR 2013
66
#define RUBY_RELEASE_MONTH 6

0 commit comments

Comments
 (0)