From 6070faa2de1fe7b388eb048c70773b4c277cd438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cyryl=20P=C5=82otnicki?= Date: Sat, 28 Nov 2020 13:28:00 +0000 Subject: [PATCH] Add perf --- .gitignore | 3 +++ Cargo.toml | 2 ++ scripts/rust-unmangle | 32 ++++++++++++++++++++++++++++++++ shell.nix | 1 + 4 files changed, 38 insertions(+) create mode 100755 scripts/rust-unmangle diff --git a/.gitignore b/.gitignore index 332008f..b294bcd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ /target **/*.rs.bk .idea/ + +perf* +flame* diff --git a/Cargo.toml b/Cargo.toml index 6572266..a2fd139 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,3 +35,5 @@ version = "1" default-features = false features = ["run-for-all", "prepush-hook", "run-cargo-check", "run-cargo-test", "run-cargo-clippy", "run-cargo-fmt"] +[profile.release] +debug = 1 diff --git a/scripts/rust-unmangle b/scripts/rust-unmangle new file mode 100755 index 0000000..96272a6 --- /dev/null +++ b/scripts/rust-unmangle @@ -0,0 +1,32 @@ +#!/usr/bin/env -S sed -rf +# Unmangle Rust symbols +# See https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=cae15db74999edb96dd9f5bbd4d55849391dd92b +# Example, with [FlameGraph](https://github.com/brendangregg/FlameGraph): +# perf record -g target/debug/bin +# perf script | stackcollapse-perf | rust-unmangle | flamegraph > perf.svg + +# Remove hash and address offset +s/::h[0-9a-f]{16}//g +s/\+0x[0-9a-f]+//g + +# Convert special characters +s/\$C\$/,/g +s/\$SP\$/@/g +s/\$BP\$/*/g +s/\$RF\$/\&/g +s/\$LT\$//g +s/\$LP\$/(/g +s/\$RP\$/)/g +s/\$u20\$/ /g +s/\$u27\$/'/g +s/\$u5b\$/[/g +s/\$u5d\$/]/g +s/\$u7b\$/{/g +s/\$u7d\$/}/g +s/\$u7e\$/~/g + +# Fix . and _ +s/\.\./::/g +s/[^\.]\.[^\.]/./g +s/([;:])_/\1/g diff --git a/shell.nix b/shell.nix index fe04ba8..a39f05d 100644 --- a/shell.nix +++ b/shell.nix @@ -8,6 +8,7 @@ in name = "bakare_shell"; buildInputs = [ channel.rust + linuxPackages.perf flamegraph cargo-flamegraph geeqie cacert openssl openssh zlib pkgconfig clang llvm git