Are there any profiling tools for Roc? It doesn't need to be anything fancy, just something that can tell me how much time is spent in a function would be very helpful in improving performance.
@Brendan Hansknecht is the expert on that :)
My advice for really useful high level profiling:
--optimize --profiling
perf
and a tool to convert that to a flame graph. Make sure to pass --call-graph dwarf
to perf
@Brendan Hansknecht why is the "Run on Linux" step necessary? Does it require a dependency that's not on Mac OS?
perf
is amazing and is Linux only
Good to know, thanks!
Ryan Bates has marked this topic as resolved.
To be fair, dtrace
can be used on macos, but it has never worked as well for me. I'm not even sure how to get it to use debug info though, so may just be a skill issue on my part.
FWIW: I tried using flamegraph-rs on a Roc binary, but it didn't give useful output. It's supposed to work on all programs, not just Rust ones, so I'm not sure if that's an issue in flamegraph-rs or in roc
Oh, important piece I forget, you need to use --linker=legacy
This would be a super helpful guide to add to the website or somwhere we can find it. It doesn't need to be very long, but I think it would help to have the procedure step by step. Or maybe we can link to it from roc-awesome? @Brendan Hansknecht do you have a blog, would you be interested in writing about your process? What do people think about adding something like this to roc-lang.org under guides?
I could write something up. Now that we have the --profiling
flag, we actually can get some useful data.
I do have a blog with I think exactly 1 article
On Mac I've used the Instruments tool. It's a GUI profiler that comes with XCode. Pretty good. Haven't used it on Roc code but it should be the same as any other binary.
I didn't need a whole XCode project or anything, just pointed it at my binary.
I should test that now that we have debug info
Instruments looks to work quite well on macos with --profiling
has a full call stack
This would be a super helpful guide to add to the website or somwhere we can find it
The examples repo seems like a great fit.
I made https://github.com/roc-lang/examples/issues/123 for it
Last updated: Jul 06 2025 at 12:14 UTC