jjsimpso
2021-4-23 16:02:46

I’m trying to understand the output of racket-mode’s racket-profile. Here’s an example of my program profiled at three different points: CALLS MSEC NAME FILE 54 46 for-loop src/widgets.rkt 1 6 init-new-tab src/tab.rkt 1 1 go method in browser-text% src/widgets.rkt 7 1 parse-dir-entity src/gopher.rkt 1 1 src/gopher.rkt 355 1 loop-mls src/gopher.rkt

108 46 for-loop src/widgets.rkt 1 6 init-new-tab src/tab.rkt 37 4 parse-dir-entity src/gopher.rkt 3 3 go method in browser-text% src/widgets.rkt 3 3 src/gopher.rkt 2384 3 loop-mls src/gopher.rkt

1051 51 parse-dir-entity src/gopher.rkt 1123 46 for-loop src/widgets.rkt 101686 25 loop-mls src/gopher.rkt 1 6 init-new-tab src/tab.rkt 4 4 go method in browser-text% src/widgets.rkt 4 4 src/gopher.rkt 4 4 gopher-fetch src/gopher.rkt 1051 3 menu-line-split src/gopher.rkt


jjsimpso
2021-4-23 16:05:06

I originally assumed that the msec time was per call since for most calls it remains relatively static as the number of calls increases. However, that isn’t the case for loop-mls. loop-mls can’t be taking 25 msec for each of 101,686 calls.


jjsimpso
2021-4-23 16:06:57

I also wonder if garbage collection time is counted. Basically my code runs quickly until it starts handling more data. At that point the execution appears to slow, but the amount of work done per function call should remain pretty consistent.


greg
2021-4-23 16:28:29

IIRC it is the total time spent.


greg
2021-4-23 16:28:45

I added this to Racket Mode some years ago, but, the spirit is to provide a way to use the errortrace-lib based profiling and give the results in an Emacs buffer that makes it easier to jump to the locations.



greg
2021-4-23 16:30:58

It basically just accumulates current-inexact-milliseconds between the register-profile-start and register-profile-stop calls from the errortrace instrumentation.


greg
2021-4-23 16:31:19

I would expect it to include GC time.


greg
2021-4-23 16:32:17

Note that any profiling using something like Racket Mode or DrRacket is probably not as trustworthy as doing it via command-line Racket. There is some risk of other things happening, complicating the results.


greg
2021-4-23 16:33:26

To the extent I’ve used this in Racket Mode, for myself — eating my own dog food — I’ve focused more on “CALLS”, taken “MSEC” with a big grain of salt, and used it mostly to challenge my intuition about roughly where the time is spent. Like, to help find a starting point, or candidate that might not have occurred to me.


greg
2021-4-23 16:34:51

^ @jjsimpso I hope that helps? Or at least, helps set expectations realistically?


greg
2021-4-23 16:36:46

greg
2021-4-23 16:38:40

Maybe see also Optimization Coach.


jjsimpso
2021-4-23 16:40:55

Thanks. So is raco profile implemented differently then? That is one thing I wasn’t sure about.


jjsimpso
2021-4-23 16:41:42

I just enabled the GC logs and I do see about 20ms of GC time, but that doesn’t account for the delay I’m seeing.


jjsimpso
2021-4-23 16:55:14

I’ll try raco profile next to get a clean run without possible interference. Thanks for your help.