[racket] how do I run profiling from DrRacket

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Sun Jan 5 13:42:55 EST 2014

I wouldn't bother profiling within DrRacket.  I think that feature might 
still be for small student programs.

For doing performance tuning, you can do *some* of it within DrRacket 
(like comparing the timings of many iterations of two different 
implementations of a function), but then you have to go to the command 
line for better accuracy.

For profiling, I recommend using "profile-thunk" 
("http://docs.racket-lang.org/profile/") from the command-line Racket, 
not from DrRacket.  Call "collect-garbage" 3 times before each use of 
"profile-thunk", to reduce GC confusing your instrumentation (and you 
might also wish to also call "collect-garbage" 3 times within the 
"profile-thunk", to better compare GC impact between different 
approaches).  Use the "render" procedure from module 
"profile/render-text" to get a text report of the profiling data.  If 
the report doesn't seem very useful (it should), then adjust the 
sampling rate, iterations, and such.

This profiler has helped save the day for some of my consulting clients, 
on multiple occasions.

Neil V.

Christopher wrote at 01/05/2014 12:35 PM:
> Greetings, racketeers.
>
> I have recently completed a port of most a large scripting language program I wrote (large by my standards, which is on the order of tens of thousands of lines of code) into pure Racket from some other scripting language, with the object of getting faster execution.
>
> Now that enough of the port is finished to begin testing and verification, I'm not seeing the performance gains I expected. I have some suspicions about where some bottlenecks may be, but I'd like to have more data. To that end, I'd like to run some profiling on my code as it's running.
>
> There appears to be some way to run profiling from DrRacket, but I can't discover the correct way to do this, for the things I'm trying bring forth strange errors when I try to run the program.
>
> I try to turn on profiling from the Choose Language menu item under Dynamic Properties, but when I select debugging and profiling, then weird errors appear that didn't happen when I had just debugging selected.
>
> For example, an identifier defined by a module imported with "require" is suddenly complained about as being undefined. An other thing that happens is this cryptic message:
>
> link: module mismatch;
>   possibly, bytecode file needs re-compile because dependencies changed
>    importing module: "/Users/christopher/Programming/Racket/organ-relay-sim/packages/organ-relay-sim/myhdl/private/delay-join.rkt"
>    exporting module: "/Users/christopher/Programming/Racket/organ-relay-sim/packages/organ-relay-sim/myhdl/private/generator.rkt"
>    exporting phase level: 0
>    internal explanation: variable not provided (directly or indirectly and at the expected position) in: stop-iteration1.1
>
> That does not happen when just debugging is selected.
>
> Any advice would be appreciated.
>
> Thanks!
>
> —Christopher


Posted on the users mailing list.