Skip to content

Instantly share code, notes, and snippets.

@sshravan
Last active November 10, 2023 19:14
Show Gist options
  • Save sshravan/2d1e78e423a93ed0b02a0d6daa656af8 to your computer and use it in GitHub Desktop.
Save sshravan/2d1e78e423a93ed0b02a0d6daa656af8 to your computer and use it in GitHub Desktop.

Enable logging

You might have to do this:

echo -1 | sudo tee /proc/sys/kernel/perf_event_paranoid

And these changes to your TOML

[profile.release]
debug = true

[profile.bench]
debug = true

CPU and RAM

URL

CPU

Use perf when on linux

perf record -F 999 -a -g -- sleep 60
./stackcollapse-perf.pl out.perf > out.folded
./flamegraph.pl out.kern_folded > kernel.svg

Use Cargo Flamegraph

(CARGO_PROFILE_BENCH_DEBUG=true; cargo flamegraph --bench full_benchmarking)

RAM

heaptrack

Needs QT if you want to run the visualization on macOS (see).

Valgrind/massif

valgrind --tool=massif --stacks=yes --verbose --peak-inaccuracy=0 --time-unit=ms --detailed-freq=1 --max-snapshots=1000 --massif-out-file=valgrind-massif.txt target/release/deps/full_benchmarking-a6de29ad1dbb7338
valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind-memcheck.txt target/release/deps/full_benchmarking-a6de29ad1dbb7338
valgrind --tool=dhat --mode=copy --verbose --dhat-out-file=valgrind-dhat-copy.txt target/release/deps/full_benchmarking-a6de29ad1dbb7338
valgrind --tool=dhat --mode=heap --verbose --dhat-out-file=valgrind-dhat-heap.txt target/release/deps/full_benchmarking-a6de29ad1dbb7338

bytehound

Works on linux.

Other URLs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment