Erlang Easy Profiling (eep)
Erlang Easy Profiling (eep) application provides a way to analyze application performance and call hierarchy.
Main features:
- no need to modify sources (doesn't need sources at all)
- no need to stop your running system
- start and stop collecting runtime data at arbitrary time
- profile arbitrary module or whole system
- minimal impact on profiled system performance (unlike [fprof] 6)
- very informative visualization of time costs and call stacks ([kcachegrind] 7)
- ability to export call graphs in dot or image format
- optional process separation
- based on [dbg] 8 module and built-in low overhead [trace ports] 9
- optionally route runtime data over network to minimize disk load
Limitations:
- doesn't work with natively compiled code
- doesn't support parent-child links (will appear in future versions)
How to
On target system:
- Make sure the target system can use eep module (link eep to your rebar project or place compiled eep.beam at any code path)
- Collect runtime data to local file
1> eep:start_file_tracing("file_name"), timer:sleep(10000), eep:stop_tracing().
- Copy $PWD/file_name.trace from the target system
Outside the target system:
- Make sure collected runtime data is in current directory ($PWD/file_name.trace)
- Convert to callgrind format
1> eep:convert_tracing("file_name").
- Start kcachegrind
$ kcachegrind callgrind.out.file_name
Also
- Collect specific module calls only
1> eep:start_file_tracing("file_name", [], [my_module_1, my_module_2]).
- Include time spent waiting for event (not running)
1> eep:convert_tracing("file_name", [waits]).
- Dump collected runtime data
1> eep:dump_tracing("file_name").
- Remove separation by erlang process
$ grep -v "^ob=" callgrind.out.file_name > callgrind.out.merged_file_name
- Route runtime data to other host, then process trace on that host
(eep@otherhost) 1> eep:start_net_client("targethost", 1088, "file_name", wait). (eep@targethost) 1> eep:start_net_tracing(1088).
Useful
- Turn off kcachegrind "cycle detection", eep detects cycles by itself
- Absolute numbers in kcachegrind are microseconds
- ELF Objects in kcachegrind are erlang pids
- By default kcachegrind limits caller depth and node cost (can be changed in call graph context menu in Graph submenu)
- Tail recursion loop within group of functions has incorrect calls and time cost values
Screenshots
- [Overall view] 1
- [Call hierarchy] 2
- [Functions navigator] 3
- [Callees ordered by cost] 4
- [Relative costs view] 5
Author
Igor Milyakov [[email protected]] 10
License
The MIT License (MIT)
Copyright (c) 2013 Igor Milyakov [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.