Don't wait for future log messages if futures are disabled (future-visualizer)

This commit is contained in:
James Swaine 2012-08-08 11:40:35 -05:00
parent 29661cc675
commit a3a55de00a
2 changed files with 59 additions and 52 deletions

View File

@ -202,12 +202,15 @@
;Gets log events for an execution timeline
;;timeline-events : (listof indexed-future-event)
(define (timeline-events)
(define sorted (sort (timeline-events/private)
#:key future-event-time
<))
(for/list ([fe (in-list sorted)]
[i (in-naturals)])
(indexed-future-event i fe)))
(cond
[(not (futures-enabled?)) '()]
[else
(define sorted (sort (timeline-events/private)
#:key future-event-time
<))
(for/list ([fe (in-list sorted)]
[i (in-naturals)])
(indexed-future-event i fe))]))
;Produces a vector of vectors, where each inner vector contains
;all the log output messages for a specific process

View File

@ -39,49 +39,53 @@ Invariants:
(future-event-time (indexed-future-event-fevent e))
i)))))]))
(define log1 (parameterize ([current-output-port (open-output-string)])
(trace-futures
(let ([fs (for/list ([i (in-range 0 1000)])
(future (λ ()
(printf "hello\n"))))])
(sleep 0.1)
(map touch fs)))))
(check-true (> (length log1) 2000))
;Event types
(check-equal? (length (filter (λ (e) (and (synchronization-event? e)
(equal? (op-name e) 'printf)))
log1))
1000)
(define syncs-len (length (filter synchronization-event? log1)))
(check-true (>= syncs-len 1000))
(check-true (<= syncs-len 2000))
(check-ordering log1)
(define tr1 (build-trace log1))
;Keys should include all unique future id's, and one entry for #f (no future context, on rt thread)
;(events logged on runtime thread outside scope of any future)
(check-equal? (length (hash-keys (trace-future-timelines tr1))) 1001)
(define log3 (trace-futures
(parameterize ([current-command-line-arguments #("2000")]
[current-output-port (open-output-string)])
(void (dynamic-require 'tests/racket/benchmarks/shootout/mandelbrot-futures #f)))))
(check-true (> (length log3) 0))
(check-true (list? (memf jitcompile-event? log3)) "No JIT compilation events found in mandelbrot")
(define tr3 (build-trace log3))
(check-equal? (length (hash-keys (trace-future-timelines tr3))) 2001)
(define log4 (trace-futures
(let ([f (future (λ ()
(for/list ([i (in-range 0 10000)])
(cons i (+ i 1)))))])
(sleep 0.5)
(touch f))))
(check-true (> (length log4) 0))
(check-true (list? (memf allocation-event? log4)) "No allocation events found in log4")
(define ae (findf allocation-event? log4))
(check-true (allocation-event? ae))
(check-true (runtime-synchronization-event? ae))
(cond
[(futures-enabled?)
(define log1 (parameterize ([current-output-port (open-output-string)])
(trace-futures
(let ([fs (for/list ([i (in-range 0 1000)])
(future (λ ()
(printf "hello\n"))))])
(sleep 0.1)
(map touch fs)))))
(check-true (> (length log1) 2000))
;Event types
(check-equal? (length (filter (λ (e) (and (synchronization-event? e)
(equal? (op-name e) 'printf)))
log1))
1000)
(define syncs-len (length (filter synchronization-event? log1)))
(check-true (>= syncs-len 1000))
(check-true (<= syncs-len 2000))
(check-ordering log1)
(define tr1 (build-trace log1))
;Keys should include all unique future id's, and one entry for #f (no future context, on rt thread)
;(events logged on runtime thread outside scope of any future)
(check-equal? (length (hash-keys (trace-future-timelines tr1))) 1001)
(define log3 (trace-futures
(parameterize ([current-command-line-arguments #("2000")]
[current-output-port (open-output-string)])
(void (dynamic-require 'tests/racket/benchmarks/shootout/mandelbrot-futures #f)))))
(check-true (> (length log3) 0))
(check-true (list? (memf jitcompile-event? log3)) "No JIT compilation events found in mandelbrot")
(define tr3 (build-trace log3))
(check-equal? (length (hash-keys (trace-future-timelines tr3))) 2001)
(define log4 (trace-futures
(let ([f (future (λ ()
(for/list ([i (in-range 0 10000)])
(cons i (+ i 1)))))])
(sleep 0.5)
(touch f))))
(check-true (> (length log4) 0))
(check-true (list? (memf allocation-event? log4)) "No allocation events found in log4")
(define ae (findf allocation-event? log4))
(check-true (allocation-event? ae))
(check-true (runtime-synchronization-event? ae))]
[else
(define l (trace-futures (let ([f (future (λ () (printf "hello\n")))])
(sleep 0.1)
(touch f))))
(check-equal? l '())])