[svn:parrot] r48585 - in trunk: src/gc t/op

nwellnhof at svn.parrot.org nwellnhof at svn.parrot.org
Fri Aug 20 14:54:32 UTC 2010


Author: nwellnhof
Date: Fri Aug 20 14:54:31 2010
New Revision: 48585
URL: https://trac.parrot.org/parrot/changeset/48585

Log:
More adjustments to GC timing

Apply the rest of my GC timing changes (TT#1737), but keep GC_ALWAYS_SKIP
for constant pools. Decrease the dynamic threshold to 25% from 50%.
This also fixes TT#945 and TT#1465.

Modified:
   trunk/src/gc/alloc_resources.c
   trunk/src/gc/gc_ms.c
   trunk/src/gc/gc_private.h
   trunk/src/gc/mark_sweep.c
   trunk/t/op/gc-leaky-box.t
   trunk/t/op/gc-leaky-call.t

Modified: trunk/src/gc/alloc_resources.c
==============================================================================
--- trunk/src/gc/alloc_resources.c	Fri Aug 20 13:50:18 2010	(r48584)
+++ trunk/src/gc/alloc_resources.c	Fri Aug 20 14:54:31 2010	(r48585)
@@ -314,7 +314,7 @@
         size_t new_mem = mem_pools->memory_used -
                          mem_pools->mem_used_last_collect;
         if (!mem_pools->gc_mark_block_level
-            && new_mem > (mem_pools->mem_used_last_collect >> 1)
+            && new_mem > (mem_pools->mem_used_last_collect >> 2)
             && new_mem > GC_SIZE_THRESHOLD) {
             Parrot_gc_mark_and_sweep(interp, GC_trace_stack_FLAG);
 
@@ -731,8 +731,7 @@
         else {
             /* Note that we don't have it any more */
             mem_pools->memory_allocated -= cur_block->size;
-            mem_pools->memory_used -=
-                cur_block->size - cur_block->free - cur_block->freed;
+            mem_pools->memory_used -= cur_block->size - cur_block->free;
 
             /* We know the pool body and pool header are a single chunk, so
              * this is enough to get rid of 'em both */

Modified: trunk/src/gc/gc_ms.c
==============================================================================
--- trunk/src/gc/gc_ms.c	Fri Aug 20 13:50:18 2010	(r48584)
+++ trunk/src/gc/gc_ms.c	Fri Aug 20 14:54:31 2010	(r48585)
@@ -1239,7 +1239,6 @@
     /* Decrease usage */
     PARROT_ASSERT(Buffer_pool(str));
     Buffer_pool(str)->freed += old_size;
-    interp->mem_pools->memory_used -= old_size;
 
     /* copy mem from strstart, *not* bufstart */
     oldmem             = str->strstart;
@@ -1509,8 +1508,8 @@
         pool->skip = GC_NO_SKIP;
     else if (pool->skip == GC_NEVER_SKIP
          || (pool->skip == GC_NO_SKIP
-         && (new_mem > (mem_pools->mem_used_last_collect >> 1)
-         &&  mem_pools->header_allocs_since_last_collect >= GC_SIZE_THRESHOLD)))
+         && (new_mem > (mem_pools->mem_used_last_collect >> 2)
+         &&  new_mem >= GC_SIZE_THRESHOLD)))
             Parrot_gc_mark_and_sweep(interp, GC_trace_stack_FLAG);
 
     /* requires that num_free_objects be updated in Parrot_gc_mark_and_sweep.
@@ -1649,9 +1648,6 @@
 
     if (alloc_size > POOL_MAX_BYTES)
         pool->objects_per_alloc = POOL_MAX_BYTES / pool->object_size;
-
-    if (alloc_size > GC_SIZE_THRESHOLD)
-        pool->skip = GC_NEVER_SKIP;
 }
 
 

Modified: trunk/src/gc/gc_private.h
==============================================================================
--- trunk/src/gc/gc_private.h	Fri Aug 20 13:50:18 2010	(r48584)
+++ trunk/src/gc/gc_private.h	Fri Aug 20 14:54:31 2010	(r48585)
@@ -86,9 +86,9 @@
 /* how often to skip a full GC when this pool has nothing free */
 typedef enum _gc_skip_type_enum {
     GC_NO_SKIP = 0,
-    GC_ONE_SKIP,
+    GC_ONE_SKIP,        /* unused */
     GC_ALWAYS_SKIP,
-    GC_NEVER_SKIP
+    GC_NEVER_SKIP       /* unused */
 } gc_skip_type_enum;
 
 typedef struct GC_Subsystem {
@@ -326,7 +326,10 @@
                                    * structures */
     size_t  memory_used;          /* The total amount of memory used
                                    * in fixed and variable size
-                                   * pools. */
+                                   * pools. Also includes memory in
+                                   * variable size pools that has been
+                                   * freed but can only be reclaimed
+                                   * by a GC run */
     size_t  mem_used_last_collect;    /* The total amount of
                                        * memory used after
                                        * the last GC run */

Modified: trunk/src/gc/mark_sweep.c
==============================================================================
--- trunk/src/gc/mark_sweep.c	Fri Aug 20 13:50:18 2010	(r48584)
+++ trunk/src/gc/mark_sweep.c	Fri Aug 20 14:54:31 2010	(r48585)
@@ -32,13 +32,11 @@
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 
 static void free_buffer(SHIM_INTERP,
-    ARGMOD(Memory_Pools *mem_pools),
+    SHIM(Memory_Pools *mem_pools),
     ARGMOD(Fixed_Size_Pool *pool),
     ARGMOD(Buffer *b))
-        __attribute__nonnull__(2)
         __attribute__nonnull__(3)
         __attribute__nonnull__(4)
-        FUNC_MODIFIES(*mem_pools)
         FUNC_MODIFIES(*pool)
         FUNC_MODIFIES(*b);
 
@@ -80,8 +78,7 @@
         FUNC_MODIFIES(*mem_pools);
 
 #define ASSERT_ARGS_free_buffer __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(mem_pools) \
-    , PARROT_ASSERT_ARG(pool) \
+       PARROT_ASSERT_ARG(pool) \
     , PARROT_ASSERT_ARG(b))
 #define ASSERT_ARGS_free_pmc_in_pool __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
@@ -659,7 +656,7 @@
 
 static void
 free_buffer(SHIM_INTERP,
-        ARGMOD(Memory_Pools *mem_pools),
+        SHIM(Memory_Pools *mem_pools),
         ARGMOD(Fixed_Size_Pool *pool),
         ARGMOD(Buffer *b))
 {
@@ -684,9 +681,7 @@
 
             /* We can have shared buffers. Don't count them (yet) */
             if (!(*buffer_flags & Buffer_shared_FLAG)) {
-                size_t size = ALIGNED_STRING_SIZE(Buffer_buflen(b));
-                block->freed += size;
-                mem_pools->memory_used -= size;
+                block->freed  += ALIGNED_STRING_SIZE(Buffer_buflen(b));
             }
 
         }

Modified: trunk/t/op/gc-leaky-box.t
==============================================================================
--- trunk/t/op/gc-leaky-box.t	Fri Aug 20 13:50:18 2010	(r48584)
+++ trunk/t/op/gc-leaky-box.t	Fri Aug 20 14:54:31 2010	(r48585)
@@ -65,9 +65,9 @@
 
     $S1 = $I3
     $S0 = "allocated " . $S1
-    $S0 .= " (which should be <= 2_000_000) bytes of memory, TODO: TT#1465"
+    $S0 .= " (which should be <= 2_000_000) bytes of memory"
     $I4 = isle $I3, 2000000
-    todo($I4,$S0)
+    ok($I4,$S0)
 .end
 
 # Local Variables:

Modified: trunk/t/op/gc-leaky-call.t
==============================================================================
--- trunk/t/op/gc-leaky-call.t	Fri Aug 20 13:50:18 2010	(r48584)
+++ trunk/t/op/gc-leaky-call.t	Fri Aug 20 14:54:31 2010	(r48585)
@@ -62,9 +62,9 @@
 
     $S1 = $I3
     $S0 = "allocated " . $S1
-    $S0 .= " (which should be <= 2_000_000) bytes of memory, TODO: TT#945"
+    $S0 .= " (which should be <= 2_000_000) bytes of memory"
     $I4 = isle $I3, 2000000
-    todo($I4,$S0)
+    ok($I4,$S0)
 .end
 
 .sub consume


More information about the parrot-commits mailing list