Erlang Profiling Tips

Srijan Choudhary Srijan Choudhary
- 1 min read

I have been using erlang recently for some of my work and private projects, and so I have decided to write about a few things there were hard to discover.

Profiling is an essential part of programming in erlang. Erlang's efficiency guide says:

Even experienced software developers often guess wrong about where the performance bottlenecks are in their programs.
Therefore, profile your program to see where the performance bottlenecks are and concentrate on optimizing them.

Using profiling tools in releases (using rebar/reltool)

So, after finishing a particularly complicated bit of code, I wanted to see how well it performed, and figure out any bottlenecks.

But, I hit a roadblock. Following the erlang manual for fprof, I tried to start it, but it wouldn't start and was giving the error:

** exception error: undefined function fprof:start/0

To make this work, I had to add tools to the list of apps in my reltool.config file. After adding this and regenerating, it all works.

Better visualization of fprof output

So, after I got the fprof output, I discovered it was a long file with a lot of data, and no easy way to make sense of it.

I tried using eprof (which gives a condensed output), and it helped, but I was still searching for a better way.

Then I stumbled upon a comment on stackoverflow, which linked to erlgrind - a script to convert the fprof output to callgrind output, which can be visualized using kcachegrind or some such tool.

Software Links

Interactions