I'm learning the profiler in MIT Scheme.  It's my understanding
(with-stack-sampling interval_ms proc) allows sampling, which interrupts
the program and records the return address on the stack.  The two counts
returned # times return address was at the top of the stack, called sampled
count and that the return address was somewhere else on the stack waiting
count.

I decided to run it on the Fibonacci sequence function, however could use
better understanding of interpreting the results.  I'm trying to find the
impact of the factorial function in the output, however could use
guidance.  Does the compiled code have any impact on spotting f's profile
data?

Thanks

(define (f n)
  (if (= n 0)
      1
      (* n (f (- n 1)))))


(with-stack-sampling 1 (lambda () (f 20000) '()))
;      Stack-sampling... done
;      34 samples
;
;      *** Waiting
;
;      31 samples in (runtime user-interface), with-notification, (let),
(lambda):
;       evaluating
;      (let ((.*notification-depth*.1-0 ...))
;        (define (swap!) (set! *notification-depth* ...) #!unspecific)
;        (shallow-fluid-bind swap! (lambda () ...) swap!))
;       for ### in
;      (let ((v ###)) (set! done? #t) v)
;
;      31 samples in (runtime rep), %repl-eval/write:
;       evaluating
;      (%repl-eval s-expression environment repl)
;       for ### in
;      (hook/repl-write ### s-expression environment repl)
;
;      31 samples in (runtime rep), cmdl/start, (let), (lambda), (let),
(lambda), (let), loop:
;       evaluating
;      (bind-abort-restart
;       cmdl
;       (lambda ()
;         (deregister-all-events)
;         (with-interrupt-mask interrupt-mask/all ...)))
;       for ### in
;      (loop ###)
;
;      31 samples in (runtime microcode-errors), define-error-handler,
(let), (lambda), (lambda):
;       evaluating
;      (handler continuation)
;       for ### in
;      (begin ### (default-error-handler continuation error-code))
;
;      31 samples in (runtime stack-sampler), with-stack-sampling:
;       evaluating
;      (with-notification
;       (lambda (output-port) (write-string "Stack-sampling" output-port))
;       (lambda () (run-with-stack-sampling sample-interval thunk)))
;       for ### in
;      (### (lambda (value profile) (write-notification-line ...) value))
;
;      31 samples in #[compiled-return-address 14 () #x28 #x110028]:
;       evaluating undefined expression
;
;      31 samples in (runtime stack-sampler), run-with-stack-sampling,
(let):
;       evaluating
;      (with-simple-restart
;       'abort
;       "Abort stack sampling."
;       (lambda () (dynamic-wind register-event ... deregister-event)))
;       for ### in
;      (let ((value-0 ###) (value-1 profile))
;        (lambda (receiver) (receiver value-0 value-1)))
;
;      31 samples in (runtime rep), %repl-eval:
;       evaluating
;      (hook/repl-eval s-expression environment repl)
;       for ### in
;      (let ((value ###))
;        (repl-history/record! (%record-ref ... 5) value)
;        value)
;
;      31 samples in (runtime rep), repl-driver, (let), do-loop:
;       evaluating
;      (if (queue-empty? queue)
;          (let (...) (%repl-eval/write ... environment repl))
;          ((dequeue! queue) repl))
;       for ### in
;      (begin ### (do-loop))
;
;
;      *** Sampled
;
;       3 samples in (runtime interrupt-handler),
after-gc-interrupt-handler:
;       evaluating
;      (begin (trigger-gc-daemons!)
;             (clear-interrupts! interrupt-bit/after-gc))
;
;      31 samples in (runtime stack-sampler),
with-stack-sampling-continuation:
;       evaluating
;      (call-with-current-continuation (lambda (continuation) (let ...
...)))
;       for ### in
;      (identity-procedure ###)
;
;
;Value: ()

Reply via email to