mirror of
git://git.code.sf.net/p/sbcl/sbcl
synced 2026-09-10 07:26:40 -04:00
Slightly improve style
This commit is contained in:
parent
357301f0f0
commit
8d9fcee60b
|
|
@ -46,16 +46,15 @@
|
|||
|
||||
(defun add-disassembly-profile-note (chunk stream dstate)
|
||||
(declare (ignore chunk stream))
|
||||
(when *samples*
|
||||
(let* ((samples *samples*)
|
||||
(counts (ensure-sample-counts samples))
|
||||
(location (sb-disassem:dstate-cur-addr dstate))
|
||||
(count (pc-sample-count location counts)))
|
||||
(binding* ((samples *samples* :exit-if-null)
|
||||
(counts (ensure-sample-counts samples))
|
||||
(location (sb-disassem:dstate-cur-addr dstate))
|
||||
(count (pc-sample-count location counts)))
|
||||
(unless (zerop count)
|
||||
(let* ((total-count (samples-trace-count samples))
|
||||
(width (length (write-to-string total-count :base 10))))
|
||||
(sb-disassem::note (format nil "~VD/~VD samples"
|
||||
width count width total-count)
|
||||
dstate))))))
|
||||
dstate)))))
|
||||
|
||||
(pushnew 'add-disassembly-profile-note sb-disassem::*default-dstate-hooks*)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
(root nil :type (or null vertex))
|
||||
(dfn 0 :type fixnum)
|
||||
(edges () :type list)
|
||||
(scc-vertices () :type list))
|
||||
(scc-vertices () :type list :read-only t))
|
||||
|
||||
(defstruct edge
|
||||
(vertex (sb-impl::missing-arg) :type vertex))
|
||||
|
|
@ -147,15 +147,15 @@
|
|||
(:constructor %make-call-graph))
|
||||
;; the value of *SAMPLE-INTERVAL* or *ALLOC-INTERVAL* at the time
|
||||
;; the graph was created (depending on the current allocation mode)
|
||||
(sample-interval (sb-impl::missing-arg) :type (real (0)))
|
||||
(sample-interval (sb-impl::missing-arg) :type (real (0)) :read-only t)
|
||||
;; the sampling-mode that was used for the profiling run
|
||||
(sampling-mode (sb-impl::missing-arg) :type sampling-mode)
|
||||
(sampling-mode (sb-impl::missing-arg) :type sampling-mode :read-only t)
|
||||
;; number of samples taken
|
||||
(nsamples (sb-impl::missing-arg) :type sb-int:index)
|
||||
(nsamples (sb-impl::missing-arg) :type sb-int:index :read-only t)
|
||||
;; threads that have been sampled
|
||||
(sampled-threads '() :type list)
|
||||
;; sample count for samples not in any function
|
||||
(elsewhere-count (sb-impl::missing-arg) :type sb-int:index))
|
||||
(elsewhere-count (sb-impl::missing-arg) :type sb-int:index :read-only t))
|
||||
|
||||
(defmethod print-object ((call-graph call-graph) stream)
|
||||
(print-unreadable-object (call-graph stream :type t :identity t)
|
||||
|
|
@ -181,13 +181,13 @@
|
|||
(start-pc-or-offset 0 :type address)
|
||||
(end-pc-or-offset 0 :type address)
|
||||
;; the name of the function
|
||||
(name nil :type t)
|
||||
(name nil :type t :read-only t)
|
||||
;; sample count for this function
|
||||
(count 0 :type fixnum)
|
||||
;; count including time spent in functions called from this one
|
||||
(accrued-count 0 :type fixnum)
|
||||
;; the debug-info that this node was created from
|
||||
(debug-info nil :type t)
|
||||
(debug-info nil :type t :read-only t)
|
||||
;; list of NODEs for functions calling this one
|
||||
(callers () :type list)
|
||||
;; the call count for the function that corresponds to this node (or NIL
|
||||
|
|
@ -339,7 +339,7 @@
|
|||
collect node))
|
||||
|
||||
;;; Value is a CALL-GRAPH for the current contents of *SAMPLES*.
|
||||
(defun make-call-graph-1 (max-depth)
|
||||
(defun make-call-graph-1 (samples max-depth)
|
||||
(let ((elsewhere-count 0))
|
||||
(with-lookup-tables ()
|
||||
(map-traces
|
||||
|
|
@ -377,17 +377,17 @@
|
|||
(incf (node-accrued-count caller)))
|
||||
(t
|
||||
(incf elsewhere-count)))))
|
||||
*samples*)
|
||||
samples)
|
||||
(let ((sorted-nodes (sort (collect-nodes) #'> :key #'node-count)))
|
||||
(loop for node in sorted-nodes and i from 1 do
|
||||
(setf (node-index node) i))
|
||||
(%make-call-graph :nsamples (samples-trace-count *samples*)
|
||||
:sample-interval (if (eq (samples-mode *samples*)
|
||||
(%make-call-graph :nsamples (samples-trace-count samples)
|
||||
:sample-interval (if (eq (samples-mode samples)
|
||||
:alloc)
|
||||
(samples-alloc-interval *samples*)
|
||||
(samples-sample-interval *samples*))
|
||||
(samples-alloc-interval samples)
|
||||
(samples-sample-interval samples))
|
||||
:sampling-mode (samples-mode *samples*)
|
||||
:sampled-threads (samples-sampled-threads *samples*)
|
||||
:sampled-threads (samples-sampled-threads samples)
|
||||
:elsewhere-count elsewhere-count
|
||||
:vertices sorted-nodes)))))
|
||||
|
||||
|
|
@ -422,13 +422,13 @@
|
|||
;;; *SAMPLES*. The result contain a list of nodes sorted by self-time
|
||||
;;; in the FLAT-NODES slot, and a dag in VERTICES, with call cycles
|
||||
;;; reduced to CYCLE structures.
|
||||
(defun make-call-graph (max-depth)
|
||||
(defun make-call-graph (samples max-depth)
|
||||
(stop-profiling)
|
||||
(show-progress "~&Computing call graph ")
|
||||
(show-progress "~&Computing call graph")
|
||||
;; I _think_ the reason for pinning all code is that the graph logic
|
||||
;; compares absolute PC locations. Wonderfully commented, it is.
|
||||
(let ((call-graph (with-code-pages-pinned (:dynamic)
|
||||
(make-call-graph-1 max-depth))))
|
||||
(make-call-graph-1 samples max-depth))))
|
||||
(show-progress "~&Finding cycles")
|
||||
#+nil
|
||||
(reduce-call-graph call-graph)
|
||||
|
|
|
|||
|
|
@ -117,6 +117,10 @@ inappropriate set of sampled threads, or possibly a profiler bug.~:@>"))
|
|||
(stop-profiling))
|
||||
,@(when report-p `((report :type ,report)))))))
|
||||
|
||||
;;; In wallclock mode, *TIMER* is an instance of either SB-THREAD:THREAD
|
||||
;;; or SB-EXT:TIMER depending on whether thread support exists.
|
||||
(defglobal *timer* nil)
|
||||
|
||||
#-win32
|
||||
(defun start-profiling (&key (max-samples *max-samples*)
|
||||
(mode *sampling-mode*)
|
||||
|
|
|
|||
|
|
@ -298,10 +298,6 @@ EXPERIMENTAL: Interface subject to change."
|
|||
(record-sample samples info pc-or-offset)
|
||||
foreign))
|
||||
|
||||
;;; In wallclock mode, *TIMER* is an instance of either SB-THREAD:THREAD
|
||||
;;; or SB-EXT:TIMER depending on whether thread support exists.
|
||||
(defglobal *timer* nil)
|
||||
|
||||
#+(and (or x86 x86-64) (not win32))
|
||||
(progn
|
||||
;; Ensure that only one thread at a time will be doing profiling stuff.
|
||||
|
|
|
|||
|
|
@ -260,8 +260,8 @@ resulting call-graph, or NIL if there are no samples (eg. right after
|
|||
calling RESET.)
|
||||
|
||||
Profiling is stopped before the call graph is generated."
|
||||
(cond (*samples*
|
||||
(let ((graph (or call-graph (make-call-graph most-positive-fixnum))))
|
||||
(acond (*samples*
|
||||
(let ((graph (or call-graph (make-call-graph it most-positive-fixnum))))
|
||||
(ecase type
|
||||
(:flat
|
||||
(print-flat graph :stream stream :max max :min-percent min-percent))
|
||||
|
|
@ -269,6 +269,6 @@ Profiling is stopped before the call graph is generated."
|
|||
(print-graph graph :stream stream :max max :min-percent min-percent))
|
||||
((nil)))
|
||||
graph))
|
||||
(t
|
||||
(format stream "~&; No samples to report.~%")
|
||||
nil)))
|
||||
(t
|
||||
(format stream "~&; No samples to report.~%")
|
||||
nil)))
|
||||
|
|
|
|||
Loading…
Reference in a new issue