X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fprofile.lisp;h=524b5fd40ff9d880eb4d7e331b16f4c987558409;hb=3bd7a97d1b11a2b0aee086ef211cae807f3dfc35;hp=a381821f1fd398826d7cb8f3aa6431aaa24124d2;hpb=a1a2c079c7654defb618baad0dddcf0eaf2ce64f;p=sbcl.git diff --git a/src/code/profile.lisp b/src/code/profile.lisp index a381821..524b5fd 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 @@ -176,26 +177,34 @@ ;; 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))) + ;; large amounts, then a single extra consed + ;; bignum tends to be proportionally negligible.) + (nbf0-integer (pcounter-integer nbf-pcounter)) + (nbf0-fixnum (pcounter-fixnum nbf-pcounter)) + (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) + (if (and (eq (pcounter-integer nbf-pcounter) + nbf0-integer) + (eq (pcounter-fixnum nbf-pcounter) + nbf0-fixnum)) + ;; common special case where we can avoid + ;; bignum arithmetic + (- dynamic-usage-1 + dynamic-usage-0) + ;; general case (- (get-bytes-consed) - (+ (pcounter-integer nbf-pcounter) - (pcounter-fixnum nbf-pcounter))))) + nbf0-integer + nbf0-fixnum + dynamic-usage-0))) (setf inner-enclosed-profiles (pcounter-or-fixnum->integer *enclosed-profiles*)) (let ((net-dticks (fastbig- dticks *enclosed-ticks*))) @@ -445,7 +454,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