How do I use the profiler libraries with GUI applications?

Has anyone had luck using profile-lib's profile-thunk (or profile-flame-graph's profile-thunk) on GUI applications? I tried a couple variants in Frosthaven Manager and consistently got no output data from profile-flame-graph's profile-thunk (even with #:threads #t ), so I suspect custodians/the GUI setup is part of the problem. It would be really sweet to have profiling information available, though.

I have not tried profile-lib's profile-thunk yet to see if it does better, though I won't expect it to. As I said, I suspect the custodians and eventspaces of being part of the problem (if there's a clean way to start the application so that these libraries work correctly, maybe I'm just missing it!). My application starts in the current eventspace so that Racket will block waiting for it, but also (between GUI Easy, the web server, and other bits) spins off other threads and several "child" eventspaces (most of which are short-lived, and each of which get their own child custodian of the current one).

I'd also be interested in other profiling or performance insight approaches for GUI applications.

I wrote my own profiler library for improving the performance sensitive areas of AcivtiyLog2. While it is a package, I never released it separately:

It works by explicitly instrumenting functions that need to be profiled (e.g. replacing define with define/profile), and calling profile-display to show the data.

There are two implementations, the one in "old.rkt" I used most and it is most reliable, but it does not handle recursive calls. The one in "main.rkt" can handle recursive calls and should have smaller runtime impact on the instrumented code but hasn't seen much use.

There is no documentation for either profiler, but the source code is commented.

Alex.

2 Likes