* gc.c: set_heaps_increment is not
called before gc_makrs of lazy sweeping because live_num not contain finalize objects. So call set_heaps_increment after lazy sweeping if free_num are not enough. And move free_min to struct rb_objspace for above. [ruby-dev:41499] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c22b223cb0
commit
28754d0aa9
@ -1,3 +1,11 @@
|
|||||||
|
Sun Jun 6 12:31:57 2010 Narihiro Nakamura <authorNari@gmail.com>
|
||||||
|
|
||||||
|
* gc.c: set_heaps_increment is not
|
||||||
|
called before gc_makrs of lazy sweeping because live_num not
|
||||||
|
contain finalize objects. So call set_heaps_increment after lazy
|
||||||
|
sweeping if free_num are not enough. And move free_min to struct
|
||||||
|
rb_objspace for above. [ruby-dev:41499]
|
||||||
|
|
||||||
Sun Jun 6 10:44:34 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sun Jun 6 10:44:34 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* array.c (rb_ary_product): need to set the length in order to get
|
* array.c (rb_ary_product): need to set the length in order to get
|
||||||
|
37
gc.c
37
gc.c
@ -327,6 +327,7 @@ typedef struct rb_objspace {
|
|||||||
RVALUE *freed;
|
RVALUE *freed;
|
||||||
size_t live_num;
|
size_t live_num;
|
||||||
size_t free_num;
|
size_t free_num;
|
||||||
|
size_t free_min;
|
||||||
size_t do_heap_free;
|
size_t do_heap_free;
|
||||||
} heap;
|
} heap;
|
||||||
struct {
|
struct {
|
||||||
@ -968,6 +969,7 @@ assign_heap_slot(rb_objspace_t *objspace)
|
|||||||
heaps->membase = membase;
|
heaps->membase = membase;
|
||||||
heaps->slot = p;
|
heaps->slot = p;
|
||||||
heaps->limit = objs;
|
heaps->limit = objs;
|
||||||
|
objspace->heap.free_num += objs;
|
||||||
pend = p + objs;
|
pend = p + objs;
|
||||||
if (lomem == 0 || lomem > p) lomem = p;
|
if (lomem == 0 || lomem > p) lomem = p;
|
||||||
if (himem < pend) himem = pend;
|
if (himem < pend) himem = pend;
|
||||||
@ -1966,14 +1968,14 @@ ready_to_gc(rb_objspace_t *objspace)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
before_gc_sweep(rb_objspace_t *objspace, size_t *free_min)
|
before_gc_sweep(rb_objspace_t *objspace)
|
||||||
{
|
{
|
||||||
freelist = 0;
|
freelist = 0;
|
||||||
objspace->heap.do_heap_free = (size_t)((heaps_used * HEAP_OBJ_LIMIT) * 0.65);
|
objspace->heap.do_heap_free = (size_t)((heaps_used * HEAP_OBJ_LIMIT) * 0.65);
|
||||||
*free_min = (size_t)((heaps_used * HEAP_OBJ_LIMIT) * 0.2);
|
objspace->heap.free_min = (size_t)((heaps_used * HEAP_OBJ_LIMIT) * 0.2);
|
||||||
if (*free_min < FREE_MIN) {
|
if (objspace->heap.free_min < FREE_MIN) {
|
||||||
objspace->heap.do_heap_free = heaps_used * HEAP_OBJ_LIMIT;
|
objspace->heap.do_heap_free = heaps_used * HEAP_OBJ_LIMIT;
|
||||||
*free_min = FREE_MIN;
|
objspace->heap.free_min = FREE_MIN;
|
||||||
}
|
}
|
||||||
objspace->heap.sweep_slots = heaps;
|
objspace->heap.sweep_slots = heaps;
|
||||||
objspace->heap.free_num = 0;
|
objspace->heap.free_num = 0;
|
||||||
@ -1985,6 +1987,11 @@ after_gc_sweep(rb_objspace_t *objspace)
|
|||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
GC_PROF_SET_MALLOC_INFO;
|
GC_PROF_SET_MALLOC_INFO;
|
||||||
|
|
||||||
|
if (objspace->heap.free_num < objspace->heap.free_min) {
|
||||||
|
set_heaps_increment(objspace);
|
||||||
|
heaps_increment(objspace);
|
||||||
|
}
|
||||||
|
|
||||||
if (malloc_increase > malloc_limit) {
|
if (malloc_increase > malloc_limit) {
|
||||||
malloc_limit += (size_t)((malloc_increase - malloc_limit) * (double)objspace->heap.live_num / (heaps_used * HEAP_OBJ_LIMIT));
|
malloc_limit += (size_t)((malloc_increase - malloc_limit) * (double)objspace->heap.live_num / (heaps_used * HEAP_OBJ_LIMIT));
|
||||||
if (malloc_limit < GC_MALLOC_LIMIT) malloc_limit = GC_MALLOC_LIMIT;
|
if (malloc_limit < GC_MALLOC_LIMIT) malloc_limit = GC_MALLOC_LIMIT;
|
||||||
@ -2025,7 +2032,6 @@ static void gc_marks(rb_objspace_t *objspace);
|
|||||||
static int
|
static int
|
||||||
gc_lazy_sweep(rb_objspace_t *objspace)
|
gc_lazy_sweep(rb_objspace_t *objspace)
|
||||||
{
|
{
|
||||||
size_t free_min;
|
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
INIT_GC_PROF_PARAMS;
|
INIT_GC_PROF_PARAMS;
|
||||||
@ -2047,13 +2053,19 @@ gc_lazy_sweep(rb_objspace_t *objspace)
|
|||||||
|
|
||||||
gc_marks(objspace);
|
gc_marks(objspace);
|
||||||
|
|
||||||
before_gc_sweep(objspace, &free_min);
|
before_gc_sweep(objspace);
|
||||||
if (free_min > (heaps_used * HEAP_OBJ_LIMIT - objspace->heap.live_num)) {
|
if (objspace->heap.free_min > (heaps_used * HEAP_OBJ_LIMIT - objspace->heap.live_num)) {
|
||||||
set_heaps_increment(objspace);
|
set_heaps_increment(objspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
GC_PROF_SWEEP_TIMER_START;
|
GC_PROF_SWEEP_TIMER_START;
|
||||||
res = lazy_sweep(objspace);
|
if(!(res = lazy_sweep(objspace))) {
|
||||||
|
after_gc_sweep(objspace);
|
||||||
|
if(freelist) {
|
||||||
|
res = TRUE;
|
||||||
|
during_gc = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
GC_PROF_SWEEP_TIMER_STOP;
|
GC_PROF_SWEEP_TIMER_STOP;
|
||||||
|
|
||||||
GC_PROF_TIMER_STOP(Qtrue);
|
GC_PROF_TIMER_STOP(Qtrue);
|
||||||
@ -2063,20 +2075,13 @@ gc_lazy_sweep(rb_objspace_t *objspace)
|
|||||||
static void
|
static void
|
||||||
gc_sweep(rb_objspace_t *objspace)
|
gc_sweep(rb_objspace_t *objspace)
|
||||||
{
|
{
|
||||||
size_t free_min = 0;
|
before_gc_sweep(objspace);
|
||||||
|
|
||||||
before_gc_sweep(objspace, &free_min);
|
|
||||||
|
|
||||||
while (objspace->heap.sweep_slots) {
|
while (objspace->heap.sweep_slots) {
|
||||||
slot_sweep(objspace, objspace->heap.sweep_slots);
|
slot_sweep(objspace, objspace->heap.sweep_slots);
|
||||||
objspace->heap.sweep_slots = objspace->heap.sweep_slots->next;
|
objspace->heap.sweep_slots = objspace->heap.sweep_slots->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (objspace->heap.free_num < free_min) {
|
|
||||||
set_heaps_increment(objspace);
|
|
||||||
heaps_increment(objspace);
|
|
||||||
}
|
|
||||||
|
|
||||||
after_gc_sweep(objspace);
|
after_gc_sweep(objspace);
|
||||||
|
|
||||||
during_gc = 0;
|
during_gc = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user