coz-rs

Rust support for the coz Causal Profiler

Documentation

Usage

First, follow the instructions in [coz] to install the coz command.

Next, coz is a profiler that, for the best results, typically requires source-level modifications of your code. To do this first add this to your Cargo.toml

toml [dependencies] coz = "0.1"

Then you'll want to either at throughput or latency tracepoints. More information on this can be found upstream. If you have something you'd wish whould execute more often, you can add:

```rust fn main() { loop { // ...

    // For example you wish this `loop` executed more iterations
    coz::progress!(); // equivalent of `COZ_PROGRESS`
}

} ```

Note that coz::progress!("name") is the equivalent of COZ_PROGRESS_NAMED as well.

If you'd like to profile the latency of an operation you can instead use:

```rust // Boy I wish this function executed more quickly... fn foo() { coz::begin!("foo");

// ...

coz::end!("foo");

} ```

After you've instrumented your code, you need to also ensure that you're compiling with DWARF debug information. To do this you'll want to configure Cargo.toml again:

toml [profile.release] debug = 1

Next up you'll build your application with cargo build --release, and then finally you can run it with coz run --- ./target/release/$your_binary.

Caveats

Known caveats so far to generate a report that collects information are:

Examples

You can find an example toy program at examples/toy.rs in this repository, and we can execute it with coz:

$ cargo build --release $ coz run --- ./target/release/examples/toy ... [profiler.cpp:75] Starting profiler thread $

That should generate profile.coz in the current directory, which if you plot that should look something like this:

plot of <code>toy.rs</code>

Note that I'm still learning myself the best sorts of applications to run on as well as the best sorts of questions to ask coz and where to put latency/throughput points. If you've got ideas or good examples, please feel free to add them here!

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.