# New Ticket Created by Mike Lambert # Please include the string: [netlabs #609] # in the subject line of all future correspondence about this issue. # <URL: http://bugs6.perl.org/rt2/Ticket/Display.html?id=609 >
Below patch simplifies the DOD high-level watermark code so it doesn't break as easily. I decided to go in and play with the REPLENISH_LEVEL_GROWTH_FACTOR and INITIAL_REPLENISH_LEVEL_FACTOR constants, and proceeded to make parrot reallocate at every new_header. I found it to be rather unintuitive to follow and make adjustments to. Below code implements REPLENISH_LEVEL_FACTOR, which is a percentage fro 0 to 1 which indicates at what point it will allocate more headers. Also gives us a speedup of roughly 1.5% :) Mike Lambert Index: resources.c =================================================================== RCS file: /cvs/public/parrot/resources.c,v retrieving revision 1.57 diff -u -r1.57 resources.c --- resources.c 20 May 2002 23:19:30 -0000 1.57 +++ resources.c 21 May 2002 21:37:47 -0000 @@ -20,9 +20,8 @@ #define CONSTANT_STRING_ALIGNMENT 4 /* Parameters for dynamic memory allocation calculations */ -#define INITIAL_REPLENISH_LEVEL_FACTOR 2 +#define REPLENISH_LEVEL_FACTOR 0.8 #define UNITS_PER_ALLOC_GROWTH_FACTOR 4 -#define REPLENISH_LEVEL_GROWTH_FACTOR 2 /* Function prototypes for static functions */ static void *mem_allocate(struct Parrot_Interp *interpreter, size_t *req_size, @@ -57,7 +56,7 @@ pool->free_entries = 0; pool->unit_size = unit_size; pool->units_per_alloc = units_per_alloc; - pool->replenish_level = units_per_alloc / INITIAL_REPLENISH_LEVEL_FACTOR; + pool->replenish_level = units_per_alloc * REPLENISH_LEVEL_FACTOR; pool->replenish = replenish; return pool; } @@ -172,9 +171,11 @@ add_to_free_pool(interpreter, pool, cur_pmc++); } + /* Update replenish_level to REPLENISH_LEVEL_FACTOR of the new pool size */ + pool->replenish_level = ( pool->replenish_level / REPLENISH_LEVEL_FACTOR + + pool->units_per_alloc ) * REPLENISH_LEVEL_FACTOR; /* Allocate more next time */ pool->units_per_alloc *= UNITS_PER_ALLOC_GROWTH_FACTOR; - pool->replenish_level *= REPLENISH_LEVEL_GROWTH_FACTOR; } PMC * @@ -251,9 +252,11 @@ cur_buffer = (Buffer *)((char *)cur_buffer + pool->unit_size); } + /* Update replenish_level to REPLENISH_LEVEL_FACTOR of the new pool size */ + pool->replenish_level = ( pool->replenish_level / REPLENISH_LEVEL_FACTOR + + pool->units_per_alloc ) * REPLENISH_LEVEL_FACTOR; /* Allocate twice as many next time */ pool->units_per_alloc *= UNITS_PER_ALLOC_GROWTH_FACTOR; - pool->replenish_level *= REPLENISH_LEVEL_GROWTH_FACTOR; } /* Get a buffer out of our free pool */