Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kzemek/erlang_pmp
FlameGraph compatible, Poor Man's Profiler inspired Erlang profiler
https://github.com/kzemek/erlang_pmp
elixir erlang flame flamegraph graph pmp profile profiler profiling
Last synced: 3 months ago
JSON representation
FlameGraph compatible, Poor Man's Profiler inspired Erlang profiler
- Host: GitHub
- URL: https://github.com/kzemek/erlang_pmp
- Owner: kzemek
- License: apache-2.0
- Created: 2018-07-23T15:06:02.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-05-12T22:40:23.000Z (over 3 years ago)
- Last Synced: 2024-09-17T08:51:49.854Z (4 months ago)
- Topics: elixir, erlang, flame, flamegraph, graph, pmp, profile, profiler, profiling
- Language: Erlang
- Size: 10.7 KB
- Stars: 12
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## erlang_pmp
[![Hex pm](http://img.shields.io/hexpm/v/erlang_pmp.svg?style=flat)](https://hex.pm/packages/erlang_pmp)
[Poor Man's Profiler](https://poormansprofiler.org/) inspired Erlang profiler.
### Running
```erlang
erlang_pmp:profile(Opts).
```#### Opts
* `duration`: duration the profiling will run for, in seconds (default: `60`).
* `processes`: list of PIDs that will be profiled, or `all` to use
[`erlang:processes()`](http://erlang.org/doc/man/erlang.html#processes-0) before taking each sample (default: `all`).
* `sleep`: sleep duration in milliseconds between taking samples (default: `10`).
* `show_pid`: if `true`, PID (or process name if registered) will be prepended to the stack trace (default: `false`).
* `filename`: path under which the profiling results will be saved (default: `/tmp/erlang_pmp.trace`).
* `include_statuses`: a list of process statuses as returned from
[`erlang:process_info(Pid, status)`](http://erlang.org/doc/man/erlang.html#process_info-2).
A stack trace will only be counted if the process status belongs to the list, or if `include_statuses` is `all` (default: `all`).
* `show_status`: if `true`, status of the process will be appended to the stack trace (default: `false`)#### Output
The output of `erlang_pmp` is meant to be used with [FlameGraph stack trace visualizer](https://github.com/brendangregg/FlameGraph):
```
git clone https://github.com/brendangregg/FlameGraph.git
FlameGraph/flamegraph.pl /tmp/erlang_pmp.trace > /tmp/erlang_pmp.svg
```#### Examples
First it is good to increase the depth of captured call stacks, which by default are 8 frames only.
```
erlang:system_flag(backtrace_depth, 128).
```The below example is useful in scenarios when we want to sample all processes to get an idea of the overall system profile. We omit the `waiting` state to focus on busy processes only.
```
erlang_pmp:profile([{duration, 30}, {include_statuses, [exiting, garbage_collecting, running, runnable, suspended]}, {show_status, true}, {show_pid, true}]).
```If the system has many processes, we sample stacks less frequently and don't show individual pids:
```
erlang_pmp:profile([{duration, 30}, {include_statuses, [exiting, garbage_collecting, running, runnable, suspended]}, {show_status, true}, {sleep,50}]).
```