The Optimization Coach DrRacket plugin can be used when editing a Typed Racket program in DrRacket. Clicking the 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 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 Show Optimization Coach entry in the 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 optimizer.
You can exit the coach by clicking the Close button.
For more information about Optimization Coach’s capabilities, see our OOPSLA 2012 paper. Note that there have been multiple extensions added since its publication.
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.
(optimization-coach-profile #:use-errortrace? [u-e? #t] body ...)
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 .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 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
Optimization Coach provides a verbose mode, which is enabled by clicking the Show More button. In verbose mode, reports that would only be displayed for hot functions are displayed for all functions instead. No profiling information is required to enable verbose mode.