# Perf-tools
Rust library for Linux perf.
The current feature is converting a perf.data file (CPU profiling) generated by the perf Linux profiler, into data for [Google pprof tool](https://github.com/google/pprof).
I tried Google's [perf_data_converter](https://github.com/google/perf_data_converter) but seems that it doesn't support the latest kernel versions (I tried [73a346a](https://github.com/google/perf_data_converter/commit/73a356ae16268e94195751b30918ec6e2355e832) with Linux 5.14). I tried to start from scratch in Rust rather than playing with the C++ code.

## Installation
```bash
cargo install perf-tools
```
## Usage
If you already have a perf.data file, just run `perf2pprof` command:
```bash
$ ls
Cargo.lock Cargo.toml cpu.pprof perf.data src target
$ perf2pprof
```
`cargo perf` command does everything as the above picture shows if you haven't run perf command yet.
## Preparation
Firstly, better to have debugging symbols for the GNU C library (`libc6-dbg` package in Ubuntu).
Secondly, the following configuration might be necessary:
```bash
$ sudo sysctl -w kernel.kptr_restrict=0
Lastly, put the following in your `Cargo.toml` file:
```
[profile.release]
debug = true
```
## Caveat
Only a minimum of information are converted. It's on my to-do list. Of course, pull requests are very welcome.