Skip to content

Erlang Profiling Tips

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.

erlang development

Related Posts

Slackbot using google cloud serverless functions

Slack bot using Google Cloud Functions to post a roundup of recently created channels

Slackbot using google cloud serverless functions

Erlang: Dialyzer HTML Reports using rebar3

How I made a custom rebar3 plugin to generate HTML reports for dialyzer warnings

Running multiple emacs daemons

Run multiple emacs daemons for different purposes and set different themes/config based on daemon name