{"id":13503094,"url":"https://github.com/jonhoo/inferno","last_synced_at":"2025-05-08T22:28:08.449Z","repository":{"id":37359387,"uuid":"167734795","full_name":"jonhoo/inferno","owner":"jonhoo","description":"A Rust port of FlameGraph","archived":false,"fork":false,"pushed_at":"2025-04-10T14:46:45.000Z","size":2961,"stargazers_count":1821,"open_issues_count":48,"forks_count":136,"subscribers_count":23,"default_branch":"main","last_synced_at":"2025-05-07T09:56:15.521Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonhoo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-01-26T20:19:46.000Z","updated_at":"2025-05-07T03:45:48.000Z","dependencies_parsed_at":"2023-12-18T23:25:41.446Z","dependency_job_id":"2dd9c1ea-9d63-45f1-8f2a-1725fe5a8ab4","html_url":"https://github.com/jonhoo/inferno","commit_stats":{"total_commits":564,"total_committers":55,"mean_commits":"10.254545454545454","dds":0.601063829787234,"last_synced_commit":"6326ced534f8dad96cf882c939171c101cca3e33"},"previous_names":[],"tags_count":59,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonhoo%2Finferno","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonhoo%2Finferno/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonhoo%2Finferno/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonhoo%2Finferno/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonhoo","download_url":"https://codeload.github.com/jonhoo/inferno/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252856500,"owners_count":21814857,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T22:02:36.854Z","updated_at":"2025-05-07T22:24:24.409Z","avatar_url":"https://github.com/jonhoo.png","language":"Rust","readme":"[![Crates.io](https://img.shields.io/crates/v/inferno.svg)](https://crates.io/crates/inferno)\n[![Documentation](https://docs.rs/inferno/badge.svg)](https://docs.rs/inferno/)\n[![Codecov](https://codecov.io/github/jonhoo/inferno/coverage.svg?branch=master)](https://codecov.io/gh/jonhoo/inferno)\n[![Dependency status](https://deps.rs/repo/github/jonhoo/inferno/status.svg)](https://deps.rs/repo/github/jonhoo/inferno)\n\nInferno is a port of parts of the [flamegraph\ntoolkit](http://www.brendangregg.com/flamegraphs.html) to Rust, with the\naim of improving the performance of the original flamegraph tools. The\nprimary focus is on speeding up the `stackcollapse-*` tools that process\noutput from various profiling tools into the \"folded\" format expected by\nthe `flamegraph` plotting tool. So far, the focus has been on parsing\nprofiling results from\n[`perf`](https://perf.wiki.kernel.org/index.php/Main_Page) and\n[DTrace](https://www.joyent.com/dtrace). At the time of writing,\n`inferno-collapse-perf` is ~20x faster than `stackcollapse-perf.pl` and\n`inferno-collapse-dtrace` is ~20x faster than `stackcollapse.pl` (see\n`compare.sh`).\n\nIt is developed in part through live coding sessions, which you can find\n[on YouTube](https://www.youtube.com/watch?v=jTpK-bNZiA4\u0026list=PLqbS7AVVErFimAvMW-kIJUwxpPvcPBCsz).\n\n## Using Inferno\n\n### As a library\n\nInferno provides a [library interface](https://docs.rs/inferno/) through\nthe `inferno` crate. This will let you collapse stacks and produce flame\ngraphs without going through the command line, and is intended for\nintegration with external Rust tools like [`cargo-flamegraph`].\n\n  [`cargo-flamegraph`]: https://github.com/ferrous-systems/cargo-flamegraph\n\n### As a binary\n\nFirst of all, you may want to look into [cargo\nflamegraph](https://github.com/ferrous-systems/cargo-flamegraph/), which\ndeals with much of the infrastructure for you!\n\nIf you want to use Inferno directly, then build your application in\nrelease mode and with debug symbols, and then [run a profiler] to gather\nprofiling data. Once you have the data, pass it through the appropriate\nInferno \"collapser\". Depending on your platform, this will look\nsomething like\n\n  [run a profiler]: http://www.brendangregg.com/FlameGraphs/cpuflamegraphs.html#Instructions\n\n```console\n$ # Linux\n# perf record --call-graph dwarf target/release/mybin\n$ perf script | inferno-collapse-perf \u003e stacks.folded\n```\n\nor\n\n```console\n$ # macOS\n$ target/release/mybin \u0026\n$ pid=$!\n# dtrace -x ustackframes=100 -n \"profile-97 /pid == $pid/ { @[ustack()] = count(); } tick-60s { exit(0); }\"  -o out.user_stacks\n$ cat out.user_stacks | inferno-collapse-dtrace \u003e stacks.folded\n```\n\nYou can also use `inferno-collapse-guess` which should work on both\nperf and DTrace samples. In the end, you'll end up with a \"folded stack\"\nfile. You can pass that file to `inferno-flamegraph` to generate a flame\ngraph SVG:\n\n```console\n$ cat stacks.folded | inferno-flamegraph \u003e flamegraph.svg\n```\n\nYou'll end up with an image like this:\n\n[![colorized flamegraph output](tests/data/flamegraph/example-perf-stacks/example-perf-stacks.svg)](tests/data/flamegraph/example-perf-stacks/example-perf-stacks.svg)\n\n### Obtaining profiling data\n\nTo profile your application, you'll need to have a \"profiler\" installed.\nThis will likely be [`perf`]() or [`bpftrace`] on Linux, and [DTrace] on\nmacOS. There are some great instructions on how to get started with\nthese tools on Brendan Gregg's [CPU Flame Graphs page].\n\n  [profiler]: https://en.wikipedia.org/wiki/Profiling_(computer_programming\n  [`perf`]: https://perf.wiki.kernel.org/index.php/Main_Page\n  [`bpftrace`]: https://github.com/iovisor/bpftrace/\n  [DTrace]: https://www.joyent.com/dtrace\n  [CPU Flame Graphs page]: http://www.brendangregg.com/FlameGraphs/cpuflamegraphs.html#Instructions\n\nOn Linux, you may need to tweak a kernel config such as\n```console\n$ echo 0 | sudo tee /proc/sys/kernel/perf_event_paranoid\n```\nto get profiling [to work](https://unix.stackexchange.com/a/14256).\n\n## Performance\n\n### Comparison to the Perl implementation\n\nTo run Inferno's performance comparison, run `./compare.sh`.\nIt requires [hyperfine](https://github.com/sharkdp/hyperfine), and you\nmust make sure you also check out Inferno's\n[submodules](https://github.blog/2016-02-01-working-with-submodules/).\nIn general, Inferno's perf and dtrace collapsers are ~20x faster than\n`stackcollapse-*`, and the sample collapser is ~10x faster.\n\n### Benchmarks\n\nInferno includes [criterion](https://github.com/bheisler/criterion.rs)\nbenchmarks in [`benches/`](benches/). Criterion saves its results in\n`target/criterion/`, and uses that to recognize changes in performance,\nwhich should make it easy to detect performance regressions while\ndeveloping bugfixes and improvements.\n\nYou can run the benchmarks with `cargo bench`. Some results (YMMV):\n\nMy desktop computer (AMD Ryzen 5 2600X) gets (`/N` means `N` cores):\n\n```\ncollapse/dtrace/1       time:   [8.2767 ms 8.2817 ms 8.2878 ms]\n                        thrpt:  [159.08 MiB/s 159.20 MiB/s 159.29 MiB/s]\ncollapse/dtrace/12      time:   [3.8631 ms 3.8819 ms 3.9019 ms]\n                        thrpt:  [337.89 MiB/s 339.63 MiB/s 341.28 MiB/s]\n\ncollapse/perf/1         time:   [16.386 ms 16.401 ms 16.416 ms]\n                        thrpt:  [182.37 MiB/s 182.53 MiB/s 182.70 MiB/s]\ncollapse/perf/12        time:   [4.8056 ms 4.8254 ms 4.8460 ms]\n                        thrpt:  [617.78 MiB/s 620.41 MiB/s 622.97 MiB/s]\n\ncollapse/sample         time:   [8.9132 ms 8.9196 ms 8.9264 ms]\n                        thrpt:  [155.49 MiB/s 155.61 MiB/s 155.72 MiB/s]\n\nflamegraph              time:   [16.071 ms 16.118 ms 16.215 ms]\n                        thrpt:  [38.022 MiB/s 38.250 MiB/s 38.363 MiB/s]\n```\n\nMy laptop (Intel Core i7-8650U) gets:\n\n```\ncollapse/dtrace/1       time:   [8.3612 ms 8.3839 ms 8.4114 ms]\n                        thrpt:  [156.74 MiB/s 157.25 MiB/s 157.68 MiB/s]\ncollapse/dtrace/8       time:   [3.4623 ms 3.4826 ms 3.5014 ms]\n                        thrpt:  [376.54 MiB/s 378.58 MiB/s 380.79 MiB/s]\n\ncollapse/perf/1         time:   [15.723 ms 15.756 ms 15.798 ms]\n                        thrpt:  [189.51 MiB/s 190.01 MiB/s 190.41 MiB/s]\ncollapse/perf/8         time:   [6.1391 ms 6.1554 ms 6.1715 ms]\n                        thrpt:  [485.09 MiB/s 486.36 MiB/s 487.65 MiB/s]\n\ncollapse/sample         time:   [9.3194 ms 9.3429 ms 9.3719 ms]\n                        thrpt:  [148.10 MiB/s 148.56 MiB/s 148.94 MiB/s]\n\nflamegraph              time:   [16.490 ms 16.503 ms 16.518 ms]\n                        thrpt:  [37.324 MiB/s 37.358 MiB/s 37.388 MiB/s]\n```\n\n## License\n\nInferno is a port of @brendangregg's awesome original\n[FlameGraph](https://github.com/brendangregg/FlameGraph) project,\nwritten in Perl, and owes its existence and pretty much of all of its\nfunctionality entirely to that project. [Like\nFlameGraph](https://github.com/brendangregg/FlameGraph/commit/76719a446d6091c88434489cc99d6355c3c3ef41),\nInferno is licensed under the [CDDL\n1.0](https://opensource.org/licenses/CDDL-1.0) to avoid any licensing\nissues. Specifically, the CDDL 1.0 grants\n\n\u003e a world-wide, royalty-free, non-exclusive license under intellectual\n\u003e property rights (other than patent or trademark) Licensable by Initial\n\u003e Developer, to use, reproduce, modify, display, perform, sublicense and\n\u003e distribute the Original Software (or portions thereof), with or\n\u003e without Modifications, and/or as part of a Larger Work; and under\n\u003e Patent Claims infringed by the making, using or selling of Original\n\u003e Software, to make, have made, use, practice, sell, and offer for sale,\n\u003e and/or otherwise dispose of the Original Software (or portions\n\u003e thereof).\n\nas long as the source is made available along with the license (3.1),\nboth of which are true since you're reading this file!\n","funding_links":[],"categories":["Rust","Performance"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonhoo%2Finferno","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonhoo%2Finferno","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonhoo%2Finferno/lists"}