Move Optimization Coach to PLaneT 2.

original commit: 2c8e5f9acb97f251bf4c9e940c440166bc5943f7
This commit is contained in:
Vincent St-Amour 2013-01-11 17:39:18 -05:00
parent 9f7a0be1f2
commit 2f8b4ba791
8 changed files with 28 additions and 88 deletions

View File

@ -1194,20 +1194,3 @@ This file defines two sorts of primitives. All of them are provided into any mod
(define-syntax-rule (for*/flvector: e ...)
(base-for/flvector: for*: e ...))
(provide optimization-coach-profile)
(require profile/sampler profile/analyzer profile/render-text)
(require racket/serialize)
(define-syntax (optimization-coach-profile stx)
(syntax-parse stx
[(_ body ...)
(ignore
#`(let ([sampler (create-sampler (current-thread) 0.005)])
body ...
(sampler 'stop)
(define samples (sampler 'get-snapshots))
(render (analyze-samples samples))
(with-output-to-file #,(string-append (path->string (syntax-source stx)) ".profile")
#:exists 'replace
(lambda () (write (serialize samples))))))]))

View File

@ -1,6 +1,4 @@
#lang setup/infotab
(define scribblings '(("scribblings/ts-reference.scrbl" (multi-page) (language 4))
("scribblings/ts-guide.scrbl" (multi-page) (language 5))))
(define drracket-tools '(("optimizer/tool/tool.rkt")))
(define drracket-tool-names '("Optimization Coach"))
("scribblings/ts-guide.scrbl" (multi-page) (language 5))))

View File

@ -161,29 +161,8 @@ cases.
@subsection[#:tag "optimization-coach"]{Optimization Coaching}
Typed Racket provides optimization coaching support to help you get the
most of its optimizer.
The @deftech{Optimization Coach} DrRacket plugin can be used when editing a
Typed Racket program in DrRacket. Clicking the @bold{Optimization Coach} 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 right-clicking on the highlighted
regions and picking the @bold{Show Optimization Info} menu entry.
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 serve as a starting point for further optimization.
Optimization Coach is also available for other Racket languages through the
@bold{Show Optimization Coach} entry in the @bold{View} menu.
When running from unytped Racket languages, Optimization Coach does not report
information about Typed Racket optimizations, and only reports information from
the Racket inliner.
The Optimization Coach package provides optimization coaching support to help
you get the most of the Typed Racket optimizer.
Similar information (albeit without in-depth explanations or advice) is
available from the command line. When compiling a Typed Racket program, setting
@ -193,38 +172,3 @@ 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 debug my-typed-program.rkt}
@subsubsection{Refining Recommendations with Profiling Information}
Given profiling information about your program, Optimization Coach can tailor
its recommendations to help you focus on the parts of your program that really
matter.
@; TODO when OC is moved to its own collect, change this, and declare exporting
@(require (for-label (only-in typed-racket/base-env/prims optimization-coach-profile)))
@defform[(optimization-coach-profile body ...)]{
To gather profiling information for use with Optimization Coach, wrap the
portion of your program that you want to profile (typically an entry point to
the program) with @racket[optimization-coach-profile].
When you next run your program, profiling information will be written to a
file, ready to be used by Optimization Coach. The output filename is
constructed by appending the @tt{.profile} suffix to the program's filename.
}
Once you have gathered profiling information, you can feed it to Optimization
Coach by specifying the profile file and clicking the @bold{Refine} button.
Optimization Coach will then reanalyze your program and produce new
recommendations.
Compared to the pre-profiling recommendations, those new recommendations should
be both more targeted and more aggressive.
Post profiling, Optimization Coach only recommends changes to functions that
had a significant impact on program performance according to profile data.
These are the functions where your tuning efforts are likely best spent.
In addition, Optimization Coach's post-profiling recommendations are more
aggressive. For example, it may recommend replacing convenient, high-level
constructs---such as structs--with more performant but lower-level ones---such
as vectors.

View File

@ -11,6 +11,9 @@ typed-scheme
(define (make-info key default use-default)
(case key
[(drscheme:toolbar-buttons)
(list (dynamic-require 'typed-racket/optimizer/tool/tool
'optimization-coach-drracket-button))]
;; If Optimization Coach is installed, load it.
(with-handlers ([exn:fail:filesystem? (lambda _ '())]) ; not found
(collection-path "optimization-coach")
(list (dynamic-require 'optimization-coach/tool
'optimization-coach-drracket-button)))]
[else (use-default key default)]))

View File

@ -10,8 +10,11 @@ typed/racket/base
(define (make-info key default use-default)
(case key
[(drscheme:toolbar-buttons)
(list (dynamic-require 'typed-racket/optimizer/tool/tool
'optimization-coach-drracket-button))]
;; If Optimization Coach is installed, load it.
(with-handlers ([exn:fail:filesystem? (lambda _ '())]) ; not found
(collection-path "optimization-coach")
(list (dynamic-require 'optimization-coach/tool
'optimization-coach-drracket-button)))]
[else (use-default key default)]))
(define make-language-info

View File

@ -10,8 +10,11 @@ typed/racket
(define (make-info key default use-default)
(case key
[(drscheme:toolbar-buttons)
(list (dynamic-require 'typed-racket/optimizer/tool/tool
'optimization-coach-drracket-button))]
;; If Optimization Coach is installed, load it.
(with-handlers ([exn:fail:filesystem? (lambda _ '())]) ; not found
(collection-path "optimization-coach")
(list (dynamic-require 'optimization-coach/tool
'optimization-coach-drracket-button)))]
[else (use-default key default)]))
(define make-language-info

View File

@ -10,8 +10,11 @@ typed/scheme/base
(define (make-info key default use-default)
(case key
[(drscheme:toolbar-buttons)
(list (dynamic-require 'typed-racket/optimizer/tool/tool
'optimization-coach-drracket-button))]
;; If Optimization Coach is installed, load it.
(with-handlers ([exn:fail:filesystem? (lambda _ '())]) ; not found
(collection-path "optimization-coach")
(list (dynamic-require 'optimization-coach/tool
'optimization-coach-drracket-button)))]
[else (use-default key default)]))
(define make-language-info

View File

@ -10,8 +10,11 @@ typed/scheme
(define (make-info key default use-default)
(case key
[(drscheme:toolbar-buttons)
(list (dynamic-require 'typed-racket/optimizer/tool/tool
'optimization-coach-drracket-button))]
;; If Optimization Coach is installed, load it.
(with-handlers ([exn:fail:filesystem? (lambda _ '())]) ; not found
(collection-path "optimization-coach")
(list (dynamic-require 'optimization-coach/tool
'optimization-coach-drracket-button)))]
[else (use-default key default)]))
(define make-language-info