XProf is a profiler that allows you to track execution time of Erlang functions. It's also able to capture arguments and results of a function calls that lasted longer than given number of milliseconds.
XProf was created to help solving performance problems of live, highly concurrent and utilized BE systems. It's often the case that high latency or big CPU usage driven by is caused by very specific requests that are triggering inefficient code. Finding this code is usually pretty difficult.
- Add xprof to your rebar.config (and optionally to reltool.config)
- Build your project
- Start xprof by executing
xprof:start()
in Erlang shell - Go to http://SERVER:7890
- Type in function that you would like to start tracing
- Start tracing clicking green button
{deps, [
...
{xprof, ".*", {git, "https://github.com/mniec/xprof.git"}}
]}.
You can configure xprof by changing xprof application variables.
Key | Default | Description |
---|---|---|
port | 7890 | Port for the web interface |
All improvements, fixes and ideas are very welcomed!
Project uses rebar3 for building and testing erlang code. WebUI part resides in xprof app's priv directory and it's already precompiled so there is no need to build JS sources in order to run xprof.
./rebar3 ct
The WebUI uses
- React.js
- ECMAScript 6
- Bootstap
- Bower
- Webpack
All sources are in priv directory. The app folder contains the sources and the build folder is a placeholder for final JS generated by webpack and then served by cowboy server (xprof's dependency).
To develop xprof in convenience following setup is recommended.
In the first terminal window start erlang xprof and sync which automatically reloads modules that have changed.
$ export REBAR_PROFILE=dev
$ ./rebar shell
> sync:go().
> xprof:start().
In the second window install all the assets and start webpack in development mode which is also going to recompile all JS files in priv directory when they are modified.
$ cd priv;
$ bower install
$ webpack -d