[PATCH] Have profiler print number of empty stack traces.

From: Vincent St-Amour (stamourv at racket-lang.org)
Date: Wed Aug 7 17:21:34 EDT 2013

---
 pkgs/profile-pkgs/profile-lib/profile/sampler.rkt |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/pkgs/profile-pkgs/profile-lib/profile/sampler.rkt b/pkgs/profile-pkgs/profile-lib/profile/sampler.rkt
index f29b0e9..dd634d2 100644
--- a/pkgs/profile-pkgs/profile-lib/profile/sampler.rkt
+++ b/pkgs/profile-pkgs/profile-lib/profile/sampler.rkt
@@ -98,6 +98,8 @@
               (set! next-id (add1 next-id))
               (hash-set! t thd id)
               id)))))
+  (define n-empty 0)
+  (define n-samples 0)
   (define (sampler)
     (sleep delay)
     (when (paused . <= . 0)
@@ -113,12 +115,16 @@
                                      #f
                                      (car cms))) ; value
                                custom-snapshots)))
+                 (define stack-trace
+                   (continuation-mark-set->context
+                    (continuation-marks t)))
+                 (when (null? stack-trace)
+                   (set! n-empty (add1 n-empty)))
+                 (set! n-samples (add1 n-samples))
                  (set! snapshots
                        (cons (list* (thread-id t)
                                     (current-process-milliseconds t)
-                                    (map intern-entry
-                                         (continuation-mark-set->context
-                                          (continuation-marks t))))
+                                    (map intern-entry stack-trace))
                              snapshots)))]
               [(custodian? t)
                (for-each loop (custodian-managed-list t super-cust))]
@@ -152,7 +158,9 @@
       [(set-tracked!) (validate arg 'sampler-controller)
                       (w/sema (set! to-track arg))]
       [(set-delay!)   (w/sema (set! delay arg))]
-      [(get-snapshots) (add-time) (cons cpu-time snapshots)]
+      [(get-snapshots) (add-time)
+                       (printf "empty = ~a / ~a\n" n-empty n-samples)
+                       (cons cpu-time snapshots)]
       [(get-custom-snapshots) custom-snapshots]
       [else (error 'sampler-controller "unknown message: ~e" msg)]))
   sampler-controller)
-- 
1.7.10.4


--Multipart_Wed_Aug__7_17:49:57_2013-1--

Posted on the dev mailing list.