All Projects → svenstaro → Cargo Profiler

svenstaro / Cargo Profiler

Licence: mit
Cargo subcommand to profile binaries

Programming Languages

rust
11053 projects

Labels

Projects that are alternatives of or similar to Cargo Profiler

cargo-clone
A cargo subcommand to fetch the source code of a Rust crate
Stars: ✭ 72 (-79.31%)
Mutual labels:  cargo
panamax
Mirror rustup and crates.io repositories, for offline Rust and cargo usage.
Stars: ✭ 119 (-65.8%)
Mutual labels:  cargo
blackjack
Build cargo dependencies with Bazel
Stars: ✭ 34 (-90.23%)
Mutual labels:  cargo
fe
A super-fast and easy to use command line fuzzy file searcher built with the rust programming language.
Stars: ✭ 23 (-93.39%)
Mutual labels:  cargo
vcpkg-rs
Build library for finding native libraries in vcpkg for Rust - Windows (msvc), Linux and macOS
Stars: ✭ 68 (-80.46%)
Mutual labels:  cargo
crm
Cargo registry manager (Cargo 注册表管理器),用于方便的管理和更换 Rust 国内镜像源
Stars: ✭ 103 (-70.4%)
Mutual labels:  cargo
build-rust
Script helper for building rustc and cargo from source on OpenBSD (without rustup)
Stars: ✭ 33 (-90.52%)
Mutual labels:  cargo
Cargo Instruments
A cargo plugin to generate Xcode Instruments trace files
Stars: ✭ 284 (-18.39%)
Mutual labels:  cargo
cargo-llvm-cov
Cargo subcommand to easily use LLVM source-based code coverage (-C instrument-coverage).
Stars: ✭ 181 (-47.99%)
Mutual labels:  cargo
cargo-wix
A cargo subcommand to build Windows installers for rust projects using the WiX Toolset
Stars: ✭ 142 (-59.2%)
Mutual labels:  cargo
project
☕️ Create node, rust, python or ruby project locally and on github (private or public)
Stars: ✭ 19 (-94.54%)
Mutual labels:  cargo
rhack
Temporary edit external crates that your project depends on
Stars: ✭ 104 (-70.11%)
Mutual labels:  cargo
broom
A disk cleaning utility for developers.
Stars: ✭ 38 (-89.08%)
Mutual labels:  cargo
cargo-testify
Watches changes in a rust project, runs test and shows friendly notification
Stars: ✭ 76 (-78.16%)
Mutual labels:  cargo
Wargo
Easy Rust to WebAssembly
Stars: ✭ 260 (-25.29%)
Mutual labels:  cargo
packagehub
An extension for displaying dependencies of projects on GitHub
Stars: ✭ 71 (-79.6%)
Mutual labels:  cargo
glitter
🌌⭐ Git tooling of the future.
Stars: ✭ 150 (-56.9%)
Mutual labels:  cargo
Cargo Lipo
Cargo subcommand to automatically create universal libraries for iOS.
Stars: ✭ 290 (-16.67%)
Mutual labels:  cargo
Cargo
📦 GitHub Action for Rust `cargo` command
Stars: ✭ 267 (-23.28%)
Mutual labels:  cargo
rustsec
Audit Cargo.lock files for dependencies with security vulnerabilities
Stars: ✭ 956 (+174.71%)
Mutual labels:  cargo

cargo-profiler

Build Status Crates.io license

Cargo subcommand to profile binaries

To install

NOTE: This subcommand can only be used on Linux machines.

First install valgrind:

$ sudo apt-get install valgrind

Then you can install cargo-profiler via cargo install.

$ cargo install cargo-profiler

Alternatively, you can clone this repo and build the binary from the source.

$ cargo build --release

Now, copy the built binary to the same directory as cargo.

$ sudo cp ./target/release/cargo-profiler $(dirname $(which cargo))/

To run

Cargo profiler currently supports callgrind and cachegrind.

You can call cargo profiler anywhere in a rust project directory with a Cargo.toml.

$ cargo profiler callgrind
$ cargo profiler cachegrind --release

You can also specify a binary directly:

$ cargo profiler callgrind --bin $PATH_TO_BINARY

To specify command line arguments to the executable being profiled, append them after a --:

$ cargo profiler callgrind --bin $PATH_TO_BINARY -- -a 3 --like this

You can chose to keep the callgrind/cachegrind output files using the --keep option

$ cargo profiler callgrind --keep

You can limit the number of functions you'd like to look at:

$ cargo profiler callgrind --bin ./target/debug/rsmat -n 10

Profiling rsmat with callgrind...

Total Instructions...198,466,456

78,346,775 (39.5%) dgemm_kernel.rs:matrixmultiply::gemm::masked_kernel
-----------------------------------------------------------------------
23,528,320 (11.9%) iter.rs:_..std..ops..Range..A....as..std..iter..Iterator..::next
-----------------------------------------------------------------------
16,824,925 (8.5%) loopmacros.rs:matrixmultiply::gemm::masked_kernel
-----------------------------------------------------------------------
10,236,864 (5.2%) mem.rs:core::mem::swap
-----------------------------------------------------------------------
7,712,846 (3.9%) memset.S:memset
-----------------------------------------------------------------------
7,197,344 (3.6%) ???:core::cmp::impls::_..impl..cmp..PartialOrd..for..usize..::lt
-----------------------------------------------------------------------
6,979,680 (3.5%) ops.rs:_..usize..as..ops..Add..::add
-----------------------------------------------------------------------

With cachegrind, you can also sort the data by a particular metric column:

$ cargo profiler cachegrind --bin ./target/debug/rsmat -n 10 --sort dr

Profiling rsmat with cachegrind...

Total Memory Accesses...320,385,356

Total L1 I-Cache Misses...371 (0%)
Total LL I-Cache Misses...308 (0%)
Total L1 D-Cache Misses...58,549 (0%)
Total LL D-Cache Misses...8,451 (0%)

 Ir  I1mr ILmr  Dr  D1mr DLmr  Dw  D1mw DLmw
0.40 0.18 0.21 0.35 0.93 1.00 0.38 0.00 0.00 dgemm_kernel.rs:matrixmultiply::gemm::masked_kernel
-----------------------------------------------------------------------
0.08 0.04 0.05 0.12 0.00 0.00 0.02 0.00 0.00 loopmacros.rs:matrixmultiply::gemm::masked_kernel
-----------------------------------------------------------------------
0.12 0.02 0.02 0.10 0.00 0.00 0.15 0.00 0.00 iter.rs:_std..ops..RangeAasstd..iter..Iterator::next
-----------------------------------------------------------------------
0.05 0.01 0.01 0.07 0.00 0.00 0.08 0.00 0.00 mem.rs:core::mem::swap
-----------------------------------------------------------------------
0.03 0.00 0.00 0.05 0.00 0.00 0.00 0.00 0.00 ???:core::cmp::impls::_implcmp..PartialOrdforusize::lt
-----------------------------------------------------------------------
0.03 0.01 0.01 0.04 0.00 0.00 0.03 0.00 0.00 ops.rs:_busizeasops..Addausize::add
-----------------------------------------------------------------------
0.04 0.01 0.01 0.04 0.00 0.00 0.03 0.00 0.00 ptr.rs:core::ptr::_implconstT::offset
-----------------------------------------------------------------------
0.02 0.01 0.00 0.03 0.00 0.00 0.01 0.00 0.00 ???:_usizeasops..Add::add
-----------------------------------------------------------------------
0.01 0.01 0.01 0.02 0.00 0.00 0.01 0.00 0.00 mem.rs:core::mem::uninitialized
-----------------------------------------------------------------------
0.02 0.01 0.01 0.02 0.00 0.00 0.04 0.00 0.00 wrapping.rs:_XorShiftRngasRng::next_u32
-----------------------------------------------------------------------


What are the cachegrind metrics?

  • Ir -> Total Instructions
  • I1mr -> Level 1 I-Cache misses
  • ILmr -> Last Level I-Cache misses
  • Dr -> Total Memory Reads
  • D1mr -> Level 1 D-Cache read misses
  • DLmr -> Last Level D-cache read misses
  • Dw -> Total Memory Writes
  • D1mw -> Level 1 D-Cache write misses
  • DLmw -> Last Level D-cache write misses

TODO

  • cmp subcommand - compare binary profiles
  • profiler macros
  • better context around expensive functions
  • support for more profiling tools
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].