diff --git a/collects/typed-scheme/scribblings/guide/optimization.scrbl b/collects/typed-scheme/scribblings/guide/optimization.scrbl index e172d74561..bcf017696b 100644 --- a/collects/typed-scheme/scribblings/guide/optimization.scrbl +++ b/collects/typed-scheme/scribblings/guide/optimization.scrbl @@ -164,60 +164,25 @@ cases. Typed Racket provides performance debugging support to help you get the most of its optimizer. -Setting the racket @seclink[#:doc '(lib -"scribblings/reference/reference.scrbl") "logging"]{logging} facilities to the -@racket['warning] level when compiling a Typed Racket program causes -the optimizer to log each optimization it performs. Setting the Racket -logging level can be done on the command line with the @racket[-W] -flag: +The @deftech{Performance Report} DrRacket plugin can be used when editing a +Typed Racket program in DrRacket. Clicking the Performance Report button +runs the optimizer and reports the results. All performed optimizations are +highlighted in green in the editor. In addition, the optimizer also reports +cases where an optimization was close to happening, but was not ultimately safe +to perform. These cases are highlighted in shades of red in the editor. The +redder the highlight, the higher the potential for optimization in the +highlighted region is. + +Additional information can be accessed by clicking on the highlighted +regions. A summary of the performed optimizations and advice on how to adjust +code to make it more amenable to optimization is provided as appropriate, and +can as a starting point for performance debugging. + +Similar information (albeit without in-depth explanations or advice) is +available from the command line. When compiling a Typed Racket program, setting +the racket @seclink[#:doc '(lib "scribblings/reference/reference.scrbl") +"logging"]{logging} facilities to the @racket['warning] level causes Typed +Racket to display performance debugging information. Setting the Racket logging +level can be done on the command line with the @racket[-W] flag: @commandline{racket -W warning my-typed-program.rkt} - -@(define log (open-output-string)) -@(define the-eval (make-base-eval)) -@(for-each the-eval - '((define sandbox-receiver - (make-log-receiver (current-logger) 'warning)) - (thread - (lambda () - (let loop () - (printf "~a\n" (vector-ref (sync sandbox-receiver) 1)) - (loop)))) - (require typed/racket))) - -For example, the addition in the following program can be optimized: -@(racketmod+eval #:eval the-eval typed/racket - (: add-two-floats : Float Float -> Float) - (define (add-two-floats x y) (+ x y))) - -@; This is very ugly, but necessary to let the log-receiver thread -@; catch up before we ask for the sandbox's output. -@; Suggestions for better solutions welcome. -@(sleep 1) - -With optimizer logging turned on, the optimization is reported: -@(commandline (get-output the-eval)) -@; TODO doing this in a sandbox breaks source location - -In addition, the optimizer also reports cases where an optimization was -close to happening, but was not ultimately safe to perform. Such missed -optimization warnings usually provide explanations as to why an -optimization could not be performed, pointing to changes to your -program that would make it more amenable to optimization. - -For example, the multiplication below cannot be safely optimized (see -above discussion about mixing reals and floats), although it may look -like it can. -@(racketmod+eval #:eval the-eval typed/racket - (: mul-int-float : Integer Float -> Real) - (define (mul-int-float x y) (* x y))) - -@; Again. -@(sleep 1) - -With optimizer logging turned on, the missed optimization is reported: -@(commandline (get-output the-eval)) -@; TODO sandboxing also breaks "unexpansion" for printing - - -@(close-eval the-eval)