Roxen.git / server / base_server / roxen.pike

version» Context lines:

Roxen.git/server/base_server/roxen.pike:6931:   }      void reinstall_gc_callbacks()   {    mapping(string:mixed) gc_params = ([ "pre_cb": 0,    "post_cb": 0,    "destruct_cb": 0,    "done_cb": 0 ]);       int gc_start; +  int gc_end;       // mapping from program name (as reported by sprintf/%O) to number of    // GC-destructed objects. Only valid in the GC's done_cb below.    mapping(string:int) gc_histogram = ([]);       // mapping from program name (as reported by sprintf/%O) to flag    // indicating whether a cycle has been reported for this program in    // the current GC report round. Cleared on every GC restart.    mapping(string:int(0..1)) reported_cycles = ([]);       if (log_gc_timestamps || log_gc_histogram || log_gc_verbose ||    log_gc_cycles) {    gc_params->pre_cb =    lambda() {    gc_start = gethrtime();    gc_histogram = ([]);    reported_cycles = ([]); -  werror("GC runs at %s", ctime(time())); +  werror("GC runs at %s.\n", ctime(time()) - "\n");    };       gc_params->post_cb =    lambda() { -  werror("GC done after %dms\n", -  (gethrtime() - gc_start) / 1000); +  gc_end = gethrtime();    };       if (log_gc_histogram || log_gc_verbose || log_gc_cycles) {    gc_params->destruct_cb =    lambda(object o) {    // NB: These calls to sprintf(%O) can    // take significant time.    string id =    sprintf("%O", object_program(o));    gc_histogram[id]++;
Roxen.git/server/base_server/roxen.pike:6981:    reported_cycles[id] = 1;    if (array(mixed) cycle = Pike.identify_cycle(o)) {    werror ("GC cycle:\n%s\n", format_cycle (cycle));    }    }    };    }       gc_params->done_cb =    lambda(int n) { +  string msg = sprintf("GC done after %dms.", (gc_end - gc_start) / 1000); +  if (n) +  msg += sprintf(" Zapped %d things.", n); +  werror(msg + "\n");    if (!n) return; -  werror("GC zapped %d things.\n", n); -  +     if (log_gc_histogram) {    mapping h = gc_histogram;    gc_histogram = ([]);    if (!sizeof(h)) return;    array i = indices(h);    array v = values(h);    sort(v, i);    werror("GC histogram:\n");    foreach(reverse(i)[..9], string p) {    werror("GC: %s: %d\n", p, h[p]);