[svn:parrot] r39537 - trunk/src/gc

chromatic at svn.parrot.org chromatic at svn.parrot.org
Sat Jun 13 19:17:15 UTC 2009


Author: chromatic
Date: Sat Jun 13 19:17:13 2009
New Revision: 39537
URL: https://trac.parrot.org/parrot/changeset/39537

Log:
[GC] Revised GC pool replenish level calculations.  The previous change in
r39215 had the unfortunate property of skipping the next mark and sweep if the
current mark and sweep freed up enough pool items to meet or exceed the
replenish threshold.  Of course, if the next time the GC runs is because the
system has run out of those pool items, there's no choice but to allocate a new
arena in the pool, increasing memory usage.

This version of the algorithm avoids the skip and instead uses the replenish
level to decide whether to allocate a new arena if the sweep didn't free enough
pool items to meet the replenish level.  This results in no ballooning
allocations when one GCable type is both the constraint and frequently
recyclable and only a slight performance reduction over the
sometimes-pathological case in r39215.  (That's fixable by not immediately
populating the free list from a freshly-allocated arena.)

Modified:
   trunk/src/gc/gc_ms.c

Modified: trunk/src/gc/gc_ms.c
==============================================================================
--- trunk/src/gc/gc_ms.c	Sat Jun 13 16:09:33 2009	(r39536)
+++ trunk/src/gc/gc_ms.c	Sat Jun 13 19:17:13 2009	(r39537)
@@ -369,18 +369,15 @@
         pool->skip = 0;
     else {
         Small_Object_Arena * const arena = pool->last_Arena;
-        if (arena) {
-            if (arena->used == arena->total_objects)
+        if (arena
+        &&  arena->used == arena->total_objects)
                 Parrot_gc_mark_and_sweep(interp, GC_trace_stack_FLAG);
-
-            if (pool->num_free_objects <= pool->replenish_level)
-                pool->skip = 1;
-        }
     }
 
     /* requires that num_free_objects be updated in Parrot_gc_mark_and_sweep.
        If gc is disabled, then we must check the free list directly. */
-    if (!pool->free_list)
+    if (!pool->free_list
+    ||   pool->num_free_objects < pool->replenish_level)
         (*pool->alloc_objects) (interp, pool);
 }
 


More information about the parrot-commits mailing list