diff --git a/collects/typed-racket/base-env/prims.rkt b/collects/typed-racket/base-env/prims.rkt index ac3d836d..1dc141a0 100644 --- a/collects/typed-racket/base-env/prims.rkt +++ b/collects/typed-racket/base-env/prims.rkt @@ -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))))))])) diff --git a/collects/typed-racket/info.rkt b/collects/typed-racket/info.rkt index 4d2cdecb..dd80c314 100644 --- a/collects/typed-racket/info.rkt +++ b/collects/typed-racket/info.rkt @@ -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)))) diff --git a/collects/typed-racket/scribblings/guide/optimization.scrbl b/collects/typed-racket/scribblings/guide/optimization.scrbl index c4e50a83..cffb7038 100644 --- a/collects/typed-racket/scribblings/guide/optimization.scrbl +++ b/collects/typed-racket/scribblings/guide/optimization.scrbl @@ -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. diff --git a/collects/typed-scheme/lang/reader.rkt b/collects/typed-scheme/lang/reader.rkt index 56eb2946..5affffd0 100644 --- a/collects/typed-scheme/lang/reader.rkt +++ b/collects/typed-scheme/lang/reader.rkt @@ -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)])) diff --git a/collects/typed/racket/base/lang/reader.rkt b/collects/typed/racket/base/lang/reader.rkt index 053ed28d..9432d448 100644 --- a/collects/typed/racket/base/lang/reader.rkt +++ b/collects/typed/racket/base/lang/reader.rkt @@ -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 diff --git a/collects/typed/racket/lang/reader.rkt b/collects/typed/racket/lang/reader.rkt index 1252857c..7ce2471b 100644 --- a/collects/typed/racket/lang/reader.rkt +++ b/collects/typed/racket/lang/reader.rkt @@ -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 diff --git a/collects/typed/scheme/base/lang/reader.rkt b/collects/typed/scheme/base/lang/reader.rkt index 490d0faa..a1873cb0 100644 --- a/collects/typed/scheme/base/lang/reader.rkt +++ b/collects/typed/scheme/base/lang/reader.rkt @@ -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 diff --git a/collects/typed/scheme/lang/reader.rkt b/collects/typed/scheme/lang/reader.rkt index a909f9f0..b3d729b9 100644 --- a/collects/typed/scheme/lang/reader.rkt +++ b/collects/typed/scheme/lang/reader.rkt @@ -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