Code Monkey home page Code Monkey logo

inferno's Introduction

Crates.io Documentation Build Status Codecov Dependency status

Inferno is a port of parts of the flamegraph toolkit to Rust, with the aim of improving the performance of the original flamegraph tools. The primary focus is on speeding up the stackcollapse-* tools that process output from various profiling tools into the "folded" format expected by the flamegraph plotting tool. So far, the focus has been on parsing profiling results from perf and DTrace. At the time of writing, inferno-collapse-perf is ~9x faster than stackcollapse-perf.pl and inferno-collapse-dtrace is ~10x faster than stackcollapse.pl (see compare.sh).

It is developed in part through live coding sessions, which you can find on YouTube.

Using Inferno

As a library

Inferno provides a library interface through the inferno crate. This will let you collapse stacks and produce flame graphs without going through the command line, and is intended for integration with external Rust tools like cargo-flamegraph.

As a binary

First of all, you may want to look into cargo flamegraph, which deals with much of the infrastructure for you!

If you want to use Inferno directly, then build your application in release mode and with debug symbols, and then run a profiler to gather profiling data. Once you have the data, pass it through the appropriate Inferno "collapser". Depending on your platform, this will look something like

$ # Linux
# perf record --call-graph dwarf target/release/mybin
$ perf script | inferno-collapse-perf > stacks.folded

or

$ # macOS
$ target/release/mybin &
$ pid=$!
# dtrace -x ustackframes=100 -n "profile-97 /pid == $pid/ { @[ustack()] = count(); } tick-60s { exit(0); }"  -o out.user_stacks
$ cat out.user_stacks | inferno-collapse-dtrace > stacks.folded

You can also use inferno-collapse-guess which should work on both perf and DTrace samples. In the end, you'll end up with a "folded stack" file. You can pass that file to inferno-flamegraph to generate a flame graph SVG:

$ cat stacks.folded | inferno-flamegraph > flamegraph.svg

You'll end up with an image like this:

colorized flamegraph output

Obtaining profiling data

To profile your application, you'll need to have a "profiler" installed. This will likely be perf or bpftrace on Linux, and DTrace on macOS. There are some great instructions on how to get started with these tools on Brendan Gregg's CPU Flame Graphs page.

On Linux, you may need to tweak a kernel config such as

$ echo 0 | sudo tee /proc/sys/kernel/perf_event_paranoid

to get profiling to work.

Performance

Comparison to the Perl implementation

To run Inferno's performance comparison, run ./compare.sh. It requires hyperfine, and you must make sure you also check out Inferno's submodules.

Collapsing benchmarks

Inferno includes criterion benchmarks of its stack collapser implementations in benches/. Criterion saves its results in target/criterion/, and uses that to recognize changes in performance, which should make it easy to detect performance regressions while developing bugfixes and improvements.

You can run the benchmarks with cargo bench. Some results (YMMV):

My desktop computer (AMD Ryzen 5 2600X) gets:

collapse/perf           time:   [14.978 ms 14.987 ms 14.996 ms]
                        thrpt:  [199.64 MiB/s 199.76 MiB/s 199.88 MiB/s]

collapse/dtrace         time:   [9.8128 ms 9.8169 ms 9.8213 ms]
                        thrpt:  [134.24 MiB/s 134.30 MiB/s 134.36 MiB/s]

My laptop (Intel Core i7-8650U) get:

collapse/perf           time:   [13.548 ms 13.573 ms 13.603 ms]
                        thrpt:  [220.07 MiB/s 220.56 MiB/s 220.97 MiB/s]

collapse/dtrace         time:   [9.1285 ms 9.1403 ms 9.1534 ms]
                        thrpt:  [144.04 MiB/s 144.24 MiB/s 144.43 MiB/s]

License

Inferno is a port of @brendangregg's awesome original FlameGraph project, written in Perl, and owes its existence and pretty much of all of its functionality entirely to that project. Like FlameGraph, Inferno is licensed under the CDDL 1.0 to avoid any licensing issues. Specifically, the CDDL 1.0 grants

a world-wide, royalty-free, non-exclusive license under intellectual property rights (other than patent or trademark) Licensable by Initial Developer, to use, reproduce, modify, display, perform, sublicense and distribute the Original Software (or portions thereof), with or without Modifications, and/or as part of a Larger Work; and under Patent Claims infringed by the making, using or selling of Original Software, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Software (or portions thereof).

as long as the source is made available along with the license (3.1), both of which are true since you're reading this file!

inferno's People

Contributors

jonhoo avatar jasonrhansen avatar kuldeep-singh-blueoptima avatar meven avatar jordichauzi avatar bcmyers avatar licenser avatar killercup avatar prismaphonic avatar busarovalex avatar messense avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.