From da11b861eb114f71de8d9aa790f333c963e1676a Mon Sep 17 00:00:00 2001 From: Juan Jose Garcia Ripoll Date: Tue, 8 Feb 2011 23:54:14 +0100 Subject: [PATCH] Nested TIME calls do not reset the GC counters. This requires reimplementing GC-STATS to have a special input value mean 'resetting the counters'. --- src/CHANGELOG | 4 ++++ src/c/alloc_2.d | 15 ++++++++------- src/lsp/mislib.lsp | 8 +++++++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/CHANGELOG b/src/CHANGELOG index 71fd98777..220d9b5ca 100755 --- a/src/CHANGELOG +++ b/src/CHANGELOG @@ -197,6 +197,10 @@ ECL 11.1.2 - EXT:GETENV coerces its input argument to type BASE-STRING. + - The garbage collector would reset the counters on every call to + SI:GC-STATS. This made nested TIME calls not to work, as the statistics of + the inner call would spoil those of the outer one. This has been fixed. + ;;; Local Variables: *** ;;; mode:text *** ;;; fill-column:79 *** diff --git a/src/c/alloc_2.d b/src/c/alloc_2.d index be78064ba..e7e25d5c2 100755 --- a/src/c/alloc_2.d +++ b/src/c/alloc_2.d @@ -1203,13 +1203,6 @@ si_gc_stats(cl_object enable) } else { old_status = Ct; } - if (enable == Cnil) { - GC_print_stats = 0; - cl_core.gc_stats = 0; - } else { - cl_core.gc_stats = 1; - GC_print_stats = (enable == @':full'); - } if (cl_core.bytes_consed == Cnil) { cl_core.bytes_consed = ecl_alloc_object(t_bignum); mpz_init2(cl_core.bytes_consed->big.big_num, 128); @@ -1219,8 +1212,16 @@ si_gc_stats(cl_object enable) /* We need fresh copies of the bignums */ size1 = _ecl_big_plus_fix(cl_core.bytes_consed, 1); size2 = _ecl_big_plus_fix(cl_core.gc_counter, 1); + } + if (enable == Cnil) { + GC_print_stats = 0; + cl_core.gc_stats = 0; + } else if (enable == MAKE_FIXNUM(0)) { mpz_set_ui(cl_core.bytes_consed->big.big_num, 0); mpz_set_ui(cl_core.gc_counter->big.big_num, 0); + } else { + cl_core.gc_stats = 1; + GC_print_stats = (enable == @':full'); } @(return size1 size2 old_status) } diff --git a/src/lsp/mislib.lsp b/src/lsp/mislib.lsp index 1243e1299..d3636d7d7 100644 --- a/src/lsp/mislib.lsp +++ b/src/lsp/mislib.lsp @@ -35,6 +35,8 @@ successfully, T is returned, else error." (setf (logical-pathname-translations host) (read in-str))) t))) +(defparameter *do-time-level* -1) + (defun do-time (closure) #-boehm-gc (let* ((real-start (get-internal-real-time)) @@ -60,7 +62,8 @@ successfully, T is returned, else error." (/ (- run-end run-start) internal-time-units-per-second) (/ (- gc-end gc-start) internal-time-units-per-second)))) #+boehm-gc - (let* (real-start + (let* ((*do-time-level* (1+ *do-time-level*)) + real-start run-start consed-start gc-no-start @@ -70,6 +73,9 @@ successfully, T is returned, else error." gc-no-end) ;; Garbage collection forces the value of counters to be updated (si::gc t) + ;; If there are no nested calls, we just reset the counters + (when (zerop *do-time-level*) (si::gc-stats 0)) + ;; but in general we copy the previous values. (multiple-value-setq (consed-start gc-no-start) (gc-stats t)) (setq real-start (get-internal-real-time) run-start (get-internal-run-time))