Branch: Tag:

1997-10-22

1997-10-22 02:37:08 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

more debug added

Rev: src/gc.c:1.19

21:   #include "pike_memory.h"   #include "pike_macros.h"   #include "pike_types.h" + #include "time_stuff.h"      #include "gc.h"   #include "main.h" -  + #include <math.h>      /* Run garbage collect approximate every time we have    * 20 percent of all arrays, objects and programs is
36:   #define MULTIPLIER 0.9   #define MARKER_CHUNK_SIZE 1023    - INT32 num_objects; - INT32 num_allocs; + INT32 num_objects =0; + INT32 num_allocs =0;   INT32 alloc_threshold = MIN_ALLOC_THRESHOLD; -  + static int in_gc = 0;    - static double objects_alloced; - static double objects_freed; + static double objects_alloced = 0.0; + static double objects_freed = 0.0;      struct callback_list gc_callbacks;   
119: Inside #if defined(DEBUG)
     #ifdef DEBUG    + time_t last_gc; +  + void dump_gc_info(void) + { +  fprintf(stderr,"Current number of objects: %ld\n",(long)num_objects); +  fprintf(stderr,"Objects allocated total : %ld\n",(long)num_allocs); +  fprintf(stderr," threshold for next gc() : %ld\n",(long)alloc_threshold); +  fprintf(stderr,"Average allocs per gc() : %f\n",objects_alloced); +  fprintf(stderr,"Average frees per gc() : %f\n",objects_freed); +  fprintf(stderr,"Second since last gc() : %ld\n", (long)TIME(0) - (long)last_gc); +  fprintf(stderr,"Projected garbage : %f\n", objects_freed * (double) num_allocs / (double) alloc_threshold); +  fprintf(stderr,"in_gc : %d\n", in_gc); + } +    TYPE_T attempt_to_identify(void *something)   {    struct array *a;
411:      void do_gc(void)   { -  static int in_gc = 0; +     double tmp;    INT32 tmp2,tmp3;    struct marker_chunk *m; -  +  double multiplier;       if(in_gc) return;    in_gc=1;
432: Inside #if defined(DEBUG)
   fprintf(stderr,"Garbage collecting ... ");    if(num_objects < 0)    fatal("Panic, less than zero objects!\n"); +  +  last_gc=TIME(0); +    #endif    -  objects_alloced*=MULTIPLIER; +  multiplier=pow(MULTIPLIER, (double) num_allocs / (double) alloc_threshold); +  objects_alloced*=multiplier;    objects_alloced += (double) num_allocs;    -  objects_freed*=MULTIPLIER; +  objects_freed*=multiplier;    objects_freed += (double) num_objects;