pike.git / src / gc.c

version» Context lines:

pike.git/src/gc.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: gc.c,v 1.201 2003/02/09 13:35:29 mast Exp $ + || $Id: gc.c,v 1.202 2003/02/09 15:30:57 mast Exp $   */      #include "global.h"      struct callback *gc_evaluator_callback=0;      #include "array.h"   #include "multiset.h"   #include "mapping.h"   #include "object.h"
pike.git/src/gc.c:26:   #include "interpret.h"   #include "bignum.h"   #include "pike_threadlib.h"      #include "gc.h"   #include "main.h"   #include <math.h>      #include "block_alloc.h"    - RCSID("$Id: gc.c,v 1.201 2003/02/09 13:35:29 mast Exp $"); + RCSID("$Id: gc.c,v 1.202 2003/02/09 15:30:57 mast Exp $");      int gc_enabled = 1;      /* These defaults are only guesses and hardly tested at all. Please improve. */   double gc_garbage_ratio_low = 0.2;   double gc_time_ratio = 0.05;   double gc_garbage_ratio_high = 0.5;      /* This slowness factor approximately corresponds to the average over    * the last ten gc rounds. (0.9 == 1 - 1/10) */
pike.git/src/gc.c:2844:    * to appropriately weight this last instance. */    multiplier=pow(gc_average_slowness,    (double) start_allocs / (double) alloc_threshold);       /* Comparisons to avoid that overflows mess up the statistics. */    if (gc_start_time > last_gc_end_time) {    last_non_gc_time = gc_start_time - last_gc_end_time;    non_gc_time = non_gc_time * multiplier +    last_non_gc_time * (1.0 - multiplier);    } -  else last_non_gc_time = 0; +  else last_non_gc_time = (cpu_time_t) -1;    last_gc_end_time = get_cpu_time();    if (last_gc_end_time > gc_start_time) {    last_gc_time = last_gc_end_time - gc_start_time;    gc_time = gc_time * multiplier +    last_gc_time * (1.0 - multiplier);    } -  else last_gc_time = 0; +  else last_gc_time = (cpu_time_t) -1;       /* At this point, unreferenced contains the number of things that    * were without external references during the check and mark    * passes. In the process of freeing them, destroy functions might    * have been called which means anything might have happened.    * Therefore we use that figure instead of the difference between    * the number of allocated things to measure the amount of    * garbage. */    last_garbage_ratio = (double) unreferenced / start_num_objs;       objects_alloced = objects_alloced * multiplier +    start_allocs * (1.0 - multiplier);    objects_freed = objects_freed * multiplier +    unreferenced * (1.0 - multiplier);    -  if (!last_non_gc_time || gc_time / non_gc_time <= gc_time_ratio) { +  if (last_non_gc_time == (cpu_time_t) -1 || +  gc_time / non_gc_time <= gc_time_ratio) {    /* Calculate the new threshold by adjusting the average    * threshold (objects_alloced) with the ratio between the wanted    * garbage at the next gc (gc_garbage_ratio_low *    * start_num_objs) and the actual average garbage    * (objects_freed). (Where the +1.0's come from I don't know.    * Perhaps they're to avoid division by zero. /mast) */    new_threshold = (objects_alloced+1.0) *    (gc_garbage_ratio_low * start_num_objs) / (objects_freed+1.0);    last_garbage_strategy = GARBAGE_RATIO_LOW;    }
pike.git/src/gc.c:2901:    new_threshold = (double)(alloc_threshold + start_allocs);   #endif       if(new_threshold < GC_MIN_ALLOC_THRESHOLD)    new_threshold = (double) GC_MIN_ALLOC_THRESHOLD;    else if(new_threshold > GC_MAX_ALLOC_THRESHOLD)    new_threshold = (double) GC_MAX_ALLOC_THRESHOLD;       alloc_threshold = (ptrdiff_t)new_threshold;    -  if (!explicit_call) { +  if (!explicit_call && last_gc_time != (cpu_time_t) -1) {   #if CPU_TIME_IS_THREAD_LOCAL == YES    OBJ2THREAD(Pike_interpreter.thread_id)->auto_gc_time += last_gc_time;   #elif CPU_TIME_IS_THREAD_LOCAL == NO    auto_gc_time += last_gc_time;   #endif    }       if(GC_VERBOSE_DO(1 ||) gc_trace)    { -  if (last_gc_time) +  if (last_gc_time != (cpu_time_t) -1)    fprintf(stderr, "done (%"PRINTSIZET"d of %"PRINTSIZET"d "    "was unreferenced), %ld ms.\n",    unreferenced, start_num_objs,    (long) (last_gc_time / (CPU_TIME_TICKS / 1000)));    else    fprintf(stderr, "done (%"PRINTSIZET"d of %"PRINTSIZET"d "    "was unreferenced)\n",    unreferenced, start_num_objs);    }    }