Skip to content

Commit

Permalink
Add support for profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
saulshanabrook committed Dec 11, 2024
1 parent 720c9d4 commit 5fb127d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,8 @@ libtest-mimic = "0.6.1"

[profile.release]
incremental = true

# https://github.com/mstange/samply/?tab=readme-ov-file#turn-on-debug-info-for-full-stacks
[profile.profiling]
inherits = "release"
debug = true
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,22 @@ We use 50ms as our cutoff currently, any benchmarks shorter than that are ignore
any benchmarks with have changes > 1% when they haven't been modified. Note that all the ignoring is done manually,
so if you add another example that's short, an admin on the codspeed project will need to manually ignore it.

## Profiling

One way to profile egglog is to use [samply](https://github.com/mstange/samply/). Here's how you can use it:

```bash
# install samply
cargo install --locked samply
# build a profile build which includes debug symbols
cargo build --profile profiling
# run the egglog file and profile
samply record ./target/profiling/egglog tests/extract-vec-bench.egg
# [optional] run the egglog file without logging or printing messages, which can help reduce the stdout
# when you are profiling extracting a large expression
env RUST_LOG=error samply record ./target/profiling/egglog --dont-print-messages tests/extract-vec-bench.egg
```

# Documentation

To view documentation, run `cargo doc --open`.
Expand Down
8 changes: 6 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ struct Args {
/// Number of times to inline leaves
#[clap(long, default_value = "0")]
serialize_n_inline_leaves: usize,
#[clap(long)]
dont_print_messages: bool,
}

// test if the current command should be evaluated
Expand Down Expand Up @@ -150,8 +152,10 @@ fn main() {
let mut egraph = mk_egraph();
match egraph.parse_and_run_program(Some(input.to_str().unwrap().into()), &program) {
Ok(msgs) => {
for msg in msgs {
println!("{msg}");
if !args.dont_print_messages {
for msg in msgs {
println!("{msg}");
}
}
}
Err(err) => {
Expand Down

0 comments on commit 5fb127d

Please sign in to comment.