- (/show0 "FUNCALLing *INTERNAL-GC*, one way or another")
- #!-gencgc (funcall *internal-gc*)
- ;; FIXME: This EQ test is pretty gross. Among its other
- ;; nastinesses, it looks as though it could break if we
- ;; recompile COLLECT-GARBAGE.
- #!+gencgc (if (eq *internal-gc* #'collect-garbage)
- (funcall *internal-gc* gen)
- (funcall *internal-gc*))
- (/show0 "back from FUNCALL to *INTERNAL-GC*")
- (let* ((post-gc-dyn-usage (dynamic-usage))
- (bytes-freed (- pre-gc-dyn-usage post-gc-dyn-usage)))
- (when *last-bytes-in-use*
- (incf *total-bytes-consed*
- (- pre-gc-dyn-usage *last-bytes-in-use*))
- (setq *last-bytes-in-use* post-gc-dyn-usage))
+ (let* (;; We do DYNAMIC-USAGE once more here in order to
+ ;; get a more accurate measurement of the space
+ ;; actually freed, since the messing around, e.g.
+ ;; GC-notify stuff, since the DYNAMIC-USAGE which
+ ;; triggered GC could've done a fair amount of
+ ;; consing.)
+ (pre-internal-gc-dynamic-usage (dynamic-usage))
+ (ignore-me
+ #!-gencgc (funcall *internal-gc*)
+ ;; FIXME: This EQ test is pretty gross. Among its other
+ ;; nastinesses, it looks as though it could break if we
+ ;; recompile COLLECT-GARBAGE. We should probably just
+ ;; straighten out the interface so that all *INTERNAL-GC*
+ ;; functions accept a GEN argument (and then the
+ ;; non-generational ones just ignore it).
+ #!+gencgc (if (eq *internal-gc* #'collect-garbage)
+ (funcall *internal-gc* gen)
+ (funcall *internal-gc*)))
+ (post-gc-dynamic-usage (dynamic-usage))
+ (n-bytes-freed (- pre-internal-gc-dynamic-usage
+ post-gc-dynamic-usage))
+ ;; In sbcl-0.6.12.39, the raw N-BYTES-FREED from
+ ;; GENCGC could sometimes be substantially negative
+ ;; (e.g. -5872). I haven't looked into what causes
+ ;; that, but I suspect it has to do with
+ ;; fluctuating inefficiency in the way that the
+ ;; GENCGC packs things into page boundaries.
+ ;; Bumping the raw result up to 0 is a little ugly,
+ ;; but shouldn't be a problem, and it's even
+ ;; possible to sort of justify it: the packing
+ ;; inefficiency which has caused (DYNAMIC-USAGE) to
+ ;; grow is effectively consing, or at least
+ ;; overhead of consing, so it's sort of correct to
+ ;; add it to the running total of consing. ("Man
+ ;; isn't a rational animal, he's a rationalizing
+ ;; animal.":-) -- WHN 2001-06-23
+ (eff-n-bytes-freed (max 0 n-bytes-freed)))
+ (declare (ignore ignore-me))
+ (/show0 "got (DYNAMIC-USAGE) and EFF-N-BYTES-FREED")
+ (incf *n-bytes-freed-or-purified*
+ eff-n-bytes-freed)
+ (/show0 "clearing *NEED-TO-COLLECT-GARBAGE*")