Author: Whiteknight
Date: Sun Jul 27 17:51:17 2008
New Revision: 29814
Modified:
branches/gsoc_pdd09/src/gc/gc_it.c
branches/gsoc_pdd09/src/gc/smallobject.c
Log:
[gsoc_pdd09] add in a skip factor, so GC doesn't run when there is probably
nothing to collect.
Modified: branches/gsoc_pdd09/src/gc/gc_it.c
==============================================================================
--- branches/gsoc_pdd09/src/gc/gc_it.c (original)
+++ branches/gsoc_pdd09/src/gc/gc_it.c Sun Jul 27 17:51:17 2008
@@ -945,6 +945,11 @@
pool->more_objects = gc_it_more_objects;
pool->free_list = NULL;
+ /* Initially, arena allocations are relatively small. Let's not try to
+ force a GC run until a few arena's are allocated. This should also
+ prevent wasting time in the GC for small one-liner programs. */
+ pool->skip = 2;
+
/* Increase allocated space to account for GC header */
pool->object_size += sizeof (Gc_it_hdr);
@@ -1346,12 +1351,24 @@
gc_it_more_objects(PARROT_INTERP, ARGMOD(Small_Object_Pool *pool))
{
const Gc_it_data * const gc_priv_data = (Gc_it_data
*)interp->arena_base->gc_private;
- const Gc_it_state state = gc_priv_data->state;
- if (state == GC_IT_SWEEP_PMCS
- || state == GC_IT_SWEEP_BUFFERS) {
- /* Do a complete sweep now, go through all sweep increments, look for
- dead objects, whatever. I'll make a function to do that. */
+ /* If the last GC run didn't turn up a lot of new objects, it's probably
+ not worthwhile to try it again. We'll skip DOD once and just go
+ straight to the new object allocation. */
+ if (pool->skip) {
+ --pool->skip;
+ }
+ else if (gc_priv_data->state >= GC_IT_END_MARK) {
+ /* If we're after the trace phase in our GC, we'll try to complete the
+ run and look for new objects. If the GC run doesn't turn up new
+ objects, allocate more. */
+ while (gc_priv_data->state != GC_IT_READY)
+ Parrot_gc_it_run(interp, 0);
+
+ /* If we don't turn up enough new objects, this pool is pretty densly
+ packed and we should skip the dod attempt next round. */
+ if (pool->num_free_objects <= pool->replenish_level)
+ ++pool->skip;
if (pool->free_list)
return;
}
Modified: branches/gsoc_pdd09/src/gc/smallobject.c
==============================================================================
--- branches/gsoc_pdd09/src/gc/smallobject.c (original)
+++ branches/gsoc_pdd09/src/gc/smallobject.c Sun Jul 27 17:51:17 2008
@@ -152,7 +152,7 @@
if (arena) {
if (arena->used == arena->total_objects)
Parrot_do_dod_run(interp, GC_trace_stack_FLAG);
-
+ /* the <= doesn't make any sense, should it be >= instead? */
if (pool->num_free_objects <= pool->replenish_level)
pool->skip = 1;
}