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

chromatic at svn.parrot.org chromatic at svn.parrot.org
Thu Sep 16 20:35:44 UTC 2010


Author: chromatic
Date: Thu Sep 16 20:35:44 2010
New Revision: 49067
URL: https://trac.parrot.org/parrot/changeset/49067

Log:
[GC] Optimized gc_ms_iterate_live_strings().

By moving the "don't do anything!" guard clauses from the buffer-moving
callback to before calling the callback, the stress_strings.pir benchmark runs
~6% faster and the callback gets called less than 10% of the time as before.
This appears to improve Rakudo's performance by about a percent as well.

We can live with this ugliness until someone either tries to make this function
more general (but please don't do that) or we get a better GC (so please help
with gc_massacre and the like).

Also the moral of the story is "Don't write C as if it were C++ and expect a
compiler which can't optimize across function pointer calls or source files to
generate fast code."

Modified:
   trunk/src/gc/gc_ms.c

Modified: trunk/src/gc/gc_ms.c
==============================================================================
--- trunk/src/gc/gc_ms.c	Thu Sep 16 18:29:40 2010	(r49066)
+++ trunk/src/gc/gc_ms.c	Thu Sep 16 20:35:44 2010	(r49067)
@@ -1924,7 +1924,11 @@
             const size_t objects_end = cur_buffer_arena->used;
 
             for (i = objects_end; i; --i) {
-                callback(interp, b, data);
+                if (Buffer_buflen(b) && PObj_is_movable_TESTALL(b)) {
+                    Memory_Block *old_block = Buffer_pool(b);
+                    if (5 * (old_block->free + old_block->freed) >= old_block->size)
+                        callback(interp, b, data);
+                }
                 b = (Buffer *)((char *)b + object_size);
             }
         }


More information about the parrot-commits mailing list