Crates.io | cargo-prof |
lib.rs | cargo-prof |
version | 0.1.9 |
source | src |
created_at | 2022-08-13 15:32:06.791532 |
updated_at | 2022-08-14 11:36:54.22373 |
description | Tools to make profiling Rust programs easier |
homepage | https://github.com/jackos/prof |
repository | https://github.com/jackos/prof |
max_upload_size | |
id | 644907 |
size | 24,534 |
This is in a very early prototyping stage and is Linux only right now, unless you're running in a docker container with valgrind
installed.
This aims to wrap profiling tools from the C/C++ ecosystem in an easy-to-use CLI that will eventually be cross-platform, providing a human-readable output as well as json
that can be piped to other tools such as UI's.
If not installed the program will print the above link.
There are two versions:
Runs on your Cargo targets
Install
cargo install cargo-prof
YAML output with bytes as text (human-readable)
cargo prof heap
allocated_total: 2KB 119B
frees: 11
allocations: 11
allocated_at_exit: 0B
blocks_at_exit: 0
JSON outputs with total bytes
cargo prof heap -j
{"allocated_total":2167,"frees":11,"allocations":11,"allocated_at_exit":0,"blocks_at_exit":0}
Runs on any binary
Install
cargo install prof
Profile ripgrep
if rg
is on your path
prof leak --bin rg
Pass ripgrep
some arguments to stress it and see if any memory leaks
prof leak --bin rg -- a -uuu
definitely_lost: 0B
indirectly_lost: 0B
possibly_lost: 528B
still_reachable: 369KB 218B
supressed: 0B
definitely_lost_blocks: 0
indrectly_lost_blocks: 0
possibly_lost_blocks: 9
still_reachable_blocks: 89
supressed_blocks: 0
Give grep
a try as well and notice some data is leaked, even on a single file:
prof leak --bin grep -- a Cargo.toml
definitely_lost: 272B
indirectly_lost: 352B
possibly_lost: 128B
still_reachable: 109KB 490B
supressed: 0B
definitely_lost_blocks: 272
indrectly_lost_blocks: 11
possibly_lost_blocks: 1
still_reachable_blocks: 15
supressed_blocks: 0
Other than leak
and heap
there is also cache
for cache misses from cachegrind
as percentages:
cargo prof cache
l1i: 0.36
l1d: 3.0
lli: 0.34
lld: 2.6
llt: 1.0
You can see a visual diagram of your cache levels with the command: lstopo
For more information on these numbers mean see official docs:
https://valgrind.org/docs/manual/cg-manual.html
Or for a good description on what a cache miss is, check out this great talk from Andrew Kelley the creator of Zig: https://vimeo.com/handmadeseattle/practical-data-oriented-design#t=280s