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.349 2010/06/22 07:03:14 mast Exp $ + || $Id: gc.c,v 1.350 2010/06/22 09:24:33 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:33:   #include <assert.h>      #include "block_alloc.h"      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; + double gc_min_time_ratio = 1.0/10001.0; /* Martys constant. */      /* This slowness factor approximately corresponds to the average over    * the last ten gc rounds. (0.9 == 1 - 1/10) */   double gc_average_slowness = 0.9;      /* The gc will free all things with no external nonweak references    * that isn't referenced by live objects. An object is considered    * "live" if it contains code that must be executed when it is    * destructed; see gc_object_is_live for details. Live objects without    * external references are then destructed and garbage collected with
pike.git/src/gc.c:476:      static INLINE void really_free_free_extra_frame (struct free_extra_frame *f)   {    free_extra_frames--;    really_free_ba_mixed_frame ((struct ba_mixed_frame *) f);   }      /* These are only collected for the sake of gc_status. */   static double last_garbage_ratio = 0.0;   static enum { -  GARBAGE_RATIO_LOW, GARBAGE_RATIO_HIGH +  GARBAGE_RATIO_LOW, GARBAGE_RATIO_HIGH, GARBAGE_MAX_INTERVAL   } last_garbage_strategy = GARBAGE_RATIO_LOW;      struct callback_list gc_callbacks;      /* These callbacks are run early in the check pass of the gc and when    * locate_references is called. They are typically used to mark    * external references (using gc_mark_external) for debug purposes. */   struct callback *debug_add_gc_callback(callback_func call,    void *arg,    callback_func free_func)
pike.git/src/gc.c:3940:    new_threshold = (objects_alloced+1.0) *    (gc_garbage_ratio_low * start_num_objs) / (objects_freed+1.0);    last_garbage_strategy = GARBAGE_RATIO_LOW;    }    else {    new_threshold = (objects_alloced+1.0) *    (gc_garbage_ratio_high * start_num_objs) / (objects_freed+1.0);    last_garbage_strategy = GARBAGE_RATIO_HIGH;    }    +  if (non_gc_time > 0.0 && gc_min_time_ratio > 0.0) { +  /* Upper limit on the new threshold based on gc_min_time_ratio. */ +  double max_threshold = (objects_alloced+1.0) * +  gc_time / (gc_min_time_ratio * non_gc_time); +  if (max_threshold < new_threshold) { +  new_threshold = max_threshold; +  last_garbage_strategy = GARBAGE_MAX_INTERVAL; +  } +  } +    #if 0    /* Afaics this is to limit the growth of the threshold to avoid    * that a single sudden allocation spike causes a very long gc    * interval the next time. Now when the bug in the decaying    * average calculation is fixed there should be no risk for that,    * at least not in any case when this would help. /mast */    if(alloc_threshold + start_allocs < new_threshold)    new_threshold = (double)(alloc_threshold + start_allocs);   #endif   
pike.git/src/gc.c:4058:    *! Garbage ratio in the last gc run.    *! @member int "non_gc_time"    *! Decaying average over the interval between gc runs, measured    *! in real time nanoseconds.    *! @member int "gc_time"    *! Decaying average over the length of the gc runs, measured in    *! real time nanoseconds.    *! @member string "last_garbage_strategy"    *! The garbage accumulation goal that the gc aimed for when    *! setting "alloc_threshold" in the last run. The value is -  *! either "garbage_ratio_low" or "garbage_ratio_high", which -  *! corresponds to the gc parameters with the same names in -  *! @[Pike.gc_parameters]. +  *! either "garbage_ratio_low", "garbage_ratio_high" or +  *! "garbage_max_interval". The first two correspond to the gc +  *! parameters with the same names in @[Pike.gc_parameters], and +  *! the last is the minimum gc time limit specified through the +  *! "min_gc_time_ratio" parameter to @[Pike.gc_parameters].    *! @member int "last_gc"    *! Time when the garbage-collector last ran.    *! @member int "total_gc_cpu_time"    *! The total amount of CPU time that has been consumed in    *! implicit GC runs, in nanoseconds. 0 on systems where Pike    *! lacks support for CPU time measurement.    *! @member int "total_gc_real_time"    *! The total amount of real time that has been spent in    *! implicit GC runs, in nanoseconds.    *! @endmapping
pike.git/src/gc.c:4120:    push_constant_text("non_gc_time");    push_int64(DO_NOT_WARN((INT64) non_gc_time));    size++;       push_constant_text("gc_time");    push_int64(DO_NOT_WARN((INT64) gc_time));    size++;       push_constant_text ("last_garbage_strategy");    switch (last_garbage_strategy) { -  case GARBAGE_RATIO_LOW: push_constant_text ("garbage_ratio_low"); break; -  case GARBAGE_RATIO_HIGH: push_constant_text ("garbage_ratio_high"); break; +  case GARBAGE_RATIO_LOW: +  push_constant_text ("garbage_ratio_low"); break; +  case GARBAGE_RATIO_HIGH: +  push_constant_text ("garbage_ratio_high"); break; +  case GARBAGE_MAX_INTERVAL: +  push_constant_text ("garbage_max_interval"); break;   #ifdef PIKE_DEBUG -  default: Pike_fatal ("Unknown last_garbage_strategy %d\n", last_garbage_strategy); +  default: +  Pike_fatal ("Unknown last_garbage_strategy %d\n", last_garbage_strategy);   #endif    }    size++;       push_constant_text("last_gc");    push_int64(last_gc);    size++;       push_constant_text ("total_gc_cpu_time");    push_int64 (auto_gc_time);
pike.git/src/gc.c:4219:    fprintf(stderr,"Avg frees per gc : %f\n",objects_freed);    fprintf(stderr,"Garbage ratio in last gc : %f\n", last_garbage_ratio);       fprintf(stderr,"Avg "CPU_TIME_UNIT" between gc : %f\n", non_gc_time);    fprintf(stderr,"Avg "CPU_TIME_UNIT" in gc : %f\n", gc_time);    fprintf(stderr,"Avg time ratio in gc : %f\n", gc_time / non_gc_time);       fprintf(stderr,"Garbage strategy in last gc: %s\n",    last_garbage_strategy == GARBAGE_RATIO_LOW ? "garbage_ratio_low" :    last_garbage_strategy == GARBAGE_RATIO_HIGH ? "garbage_ratio_high" : -  "???"); +  last_garbage_strategy == GARBAGE_MAX_INTERVAL ? +  "garbage_max_interval" : "???");      #ifdef PIKE_DEBUG    fprintf(stderr,"Max used recursion frames : %u\n", tot_max_rec_frames);    fprintf(stderr,"Max used link frames : %u\n", tot_max_link_frames);    fprintf(stderr,"Max used free extra frames : %u\n", tot_max_free_extra_frames);    fprintf(stderr,"Marked live ratio : %g\n",    (double) tot_mark_live / tot_cycle_checked);    fprintf(stderr,"Frame rotation ratio : %g\n",    (double) tot_frame_rot / tot_cycle_checked);   #endif