Stream: beginners

Topic: ✔ Profiling


view this post on Zulip Ryan Bates (Dec 08 2023 at 17:28):

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.

view this post on Zulip Anton (Dec 08 2023 at 17:29):

@Brendan Hansknecht is the expert on that :)

view this post on Zulip Brendan Hansknecht (Dec 08 2023 at 17:31):

My advice for really useful high level profiling:

  1. Run on Linux
  2. Compile with --optimize --profiling
  3. Use perf and a tool to convert that to a flame graph. Make sure to pass --call-graph dwarf to perf

view this post on Zulip Ryan Bates (Dec 08 2023 at 17:43):

@Brendan Hansknecht why is the "Run on Linux" step necessary? Does it require a dependency that's not on Mac OS?

view this post on Zulip Brendan Hansknecht (Dec 08 2023 at 17:50):

perf is amazing and is Linux only

view this post on Zulip Ryan Bates (Dec 08 2023 at 17:50):

Good to know, thanks!

view this post on Zulip Notification Bot (Dec 08 2023 at 17:50):

Ryan Bates has marked this topic as resolved.

view this post on Zulip Brendan Hansknecht (Dec 08 2023 at 17:51):

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.

view this post on Zulip LoipesMas (Dec 08 2023 at 17:58):

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

view this post on Zulip Brendan Hansknecht (Dec 08 2023 at 18:21):

Oh, important piece I forget, you need to use --linker=legacy

view this post on Zulip Luke Boswell (Dec 08 2023 at 18:45):

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?

view this post on Zulip Brendan Hansknecht (Dec 08 2023 at 18:51):

I could write something up. Now that we have the --profiling flag, we actually can get some useful data.

view this post on Zulip Brendan Hansknecht (Dec 08 2023 at 18:51):

I do have a blog with I think exactly 1 article

view this post on Zulip Brian Carroll (Dec 08 2023 at 18:57):

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.

view this post on Zulip Brian Carroll (Dec 08 2023 at 18:59):

I didn't need a whole XCode project or anything, just pointed it at my binary.

view this post on Zulip Brendan Hansknecht (Dec 08 2023 at 19:00):

I should test that now that we have debug info

view this post on Zulip Brendan Hansknecht (Dec 09 2023 at 01:30):

Instruments looks to work quite well on macos with --profiling has a full call stack

view this post on Zulip Anton (Dec 10 2023 at 13:01):

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.

view this post on Zulip Anton (Dec 10 2023 at 13:03):

I made https://github.com/roc-lang/examples/issues/123 for it


Last updated: Jul 06 2025 at 12:14 UTC