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.348 2010/05/30 09:43:06 mast Exp $ + || $Id: gc.c,v 1.349 2010/06/22 07:03:14 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:114:   time_t last_gc;   int gc_trace = 0, gc_debug = 0;   #ifdef DO_PIKE_CLEANUP   int gc_destruct_everything = 0;   #endif   size_t gc_ext_weak_refs;      static double objects_alloced = 0.0;   static double objects_freed = 0.0;   static double gc_time = 0.0, non_gc_time = 0.0; - static cpu_time_t last_gc_end_time = 0; + static cpu_time_t last_gc_end_real_time = -1;   cpu_time_t auto_gc_time = 0;   cpu_time_t auto_gc_real_time = 0;      struct link_frame /* See cycle checking blurb below. */   {    void *data;    struct link_frame *prev; /* Previous frame in the link stack. */    gc_cycle_check_cb *checkfn; /* Function to call to recurse the thing. */    int weak; /* Weak flag to checkfn. */   };
pike.git/src/gc.c:3888:    * alloc_threshold and we're using gc_average_slowness in the    * decaying average calculation. Otherwise this is either an    * explicit call (start_allocs < alloc_threshold) or the gc has    * been delayed past its due time (start_allocs >    * alloc_threshold), and in those cases we adjust the multiplier    * to give the appropriate weight to 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; +  if (last_gc_end_real_time != -1 && +  gc_start_real_time > last_gc_end_real_time) { +  last_non_gc_time = gc_start_real_time - last_gc_end_real_time;    non_gc_time = non_gc_time * multiplier +    last_non_gc_time * (1.0 - multiplier);    }    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; +  last_gc_end_real_time = get_real_time(); +  if (last_gc_end_real_time > gc_start_real_time) {    gc_time = gc_time * multiplier + -  last_gc_time * (1.0 - multiplier); +  (last_gc_end_real_time - gc_start_real_time) * (1.0 - multiplier);    } -  else last_gc_time = (cpu_time_t) -1; +  { +  cpu_time_t gc_end_time = get_cpu_time(); +  if (gc_end_time > gc_start_time) +  last_gc_time = gc_end_time - gc_start_time; +  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;   
pike.git/src/gc.c:4044:    *! Estimation of the current amount of garbage.    *! @member int "objects_alloced"    *! Decaying average over the number of allocated objects    *! between gc runs.    *! @member int "objects_freed"    *! Decaying average over the number of freed objects in each gc    *! run.    *! @member float "last_garbage_ratio"    *! Garbage ratio in the last gc run.    *! @member int "non_gc_time" -  *! Decaying average over the CPU milliseconds spent outside the -  *! garbage collector. +  *! Decaying average over the interval between gc runs, measured +  *! in real time nanoseconds.    *! @member int "gc_time" -  *! Decaying average over the CPU milliseconds spent inside the -  *! garbage collector. +  *! 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].    *! @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
pike.git/src/gc.c:4206:    num_allocs);    fprintf(stderr,"Threshold for next gc : "PRINT_ALLOC_COUNT_TYPE"\n",    alloc_threshold);    fprintf(stderr,"Projected current garbage : %f\n",    objects_freed * (double) num_allocs / (double) alloc_threshold);       fprintf(stderr,"Avg allocs between gc : %f\n",objects_alloced);    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 "CPU_TIME_UNIT" between gc : %f\n", non_gc_time); -  fprintf(stderr,"Avg cpu "CPU_TIME_UNIT" in gc : %f\n", gc_time); +  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" :    "???");      #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);