X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcode%2Fprofile.lisp;h=02fc54a6c1a44295af0d80aeb83ebddf8d68a576;hb=bee53328c93be3433477821131ab805557476c8b;hp=c156fdd82dcc07f438a64f0a1181c78c1f409d44;hpb=b4dcc81361b084a1ed9e3212ae4abbb174720780;p=sbcl.git diff --git a/src/code/profile.lisp b/src/code/profile.lisp index c156fdd..02fc54a 100644 --- a/src/code/profile.lisp +++ b/src/code/profile.lisp @@ -94,6 +94,7 @@ (total (required-argument) :type single-float :read-only t)) (defvar *overhead*) (declaim (type overhead *overhead*)) +(makunbound '*overhead*) ; in case we reload this file when tweaking ;;;; profile encapsulations @@ -168,32 +169,24 @@ (*enclosed-ticks* 0) (*enclosed-consing* 0) (*enclosed-profiles* 0) - (nbf-pcounter *n-bytes-freed-or-purified-pcounter*) - ;; Typically NBF-PCOUNTER will represent a bignum. - ;; In general we don't want to cons up a new bignum for every - ;; encapsulated call, so instead we keep track of - ;; the PCOUNTER internals, so that as long as we - ;; only cons small amounts, we'll almost always - ;; just do fixnum arithmetic. (And for encapsulated - ;; functions which cons large amounts, then we don't - ;; much care about a single extra consed bignum.) - (start-consing-integer (pcounter-integer nbf-pcounter)) - (start-consing-fixnum (pcounter-fixnum nbf-pcounter))) + (nbf0 *n-bytes-freed-or-purified*) + (dynamic-usage-0 (sb-kernel:dynamic-usage))) (declare (inline pcounter-or-fixnum->integer)) (multiple-value-prog1 (multiple-value-call encapsulated-fun (sb-c:%more-arg-values arg-context 0 arg-count)) - (let ((*computing-profiling-data-for* encapsulated-fun)) + (let ((*computing-profiling-data-for* encapsulated-fun) + (dynamic-usage-1 (sb-kernel:dynamic-usage))) (setf dticks (fastbig- (get-internal-ticks) start-ticks)) (setf dconsing - (if (eq (pcounter-integer nbf-pcounter) - start-consing-integer) - (- (pcounter-fixnum nbf-pcounter) - start-consing-fixnum) - (- (get-bytes-consed) - (+ pcounter-integer pcounter-fixnum)))) + (if (eql *n-bytes-freed-or-purified* nbf0) + ;; common special case where we can avoid + ;; bignum arithmetic + (- dynamic-usage-1 dynamic-usage-0) + ;; general case + (- (get-bytes-consed) nbf0 dynamic-usage-0))) (setf inner-enclosed-profiles (pcounter-or-fixnum->integer *enclosed-profiles*)) (let ((net-dticks (fastbig- dticks *enclosed-ticks*))) @@ -443,7 +436,7 @@ Lisp process." ;;; that I (WHN) use for my own experimentation, but it might ;;; become supported someday. Comments?) (declaim (type unsigned-byte *timer-overhead-iterations*)) -(defvar *timer-overhead-iterations* +(defparameter *timer-overhead-iterations* 500000) ;;; a dummy function that we profile to find profiling overhead