Skip to content

Commit

Permalink
chore: bump iai-callgrind
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Nov 21, 2024
1 parent 9ad12eb commit 666f82a
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 60 deletions.
13 changes: 13 additions & 0 deletions .github/scripts/install_iai_callgrind_runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -eo pipefail

echo "::group::Install"
version=$(cargo metadata --format-version=1 |\
jq '.packages[] | select(.name == "iai-callgrind").version' |\
tr -d '"'
)
cargo binstall iai-callgrind-runner --version "$version" --no-confirm --no-symlinks --force
echo "::endgroup::"
echo "::group::Verification"
which iai-callgrind-runner
echo "::endgroup::"
17 changes: 4 additions & 13 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

env:
Expand Down Expand Up @@ -32,18 +31,6 @@ jobs:
- uses: dtolnay/rust-toolchain@stable
- name: Install cargo-binstall
uses: taiki-e/install-action@cargo-binstall
- name: Install iai-callgrind-runner
run: |
echo "::group::Install"
version=$(cargo metadata --format-version=1 |\
jq '.packages[] | select(.name == "iai-callgrind").version' |\
tr -d '"'
)
cargo binstall iai-callgrind-runner --version $version --no-confirm --no-symlinks --force
echo "::endgroup::"
echo "::group::Verification"
which iai-callgrind-runner
echo "::endgroup::"
- name: Checkout base
uses: actions/checkout@v4
with:
Expand All @@ -55,11 +42,15 @@ jobs:
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Install iai-callgrind-runner
run: ./.github/scripts/install_iai_callgrind_runner.sh
- name: Save baseline
run: cargo bench -p revmc-cli --bench iai -- --save-baseline=$BASELINE
- name: Checkout PR
uses: actions/checkout@v4
with:
clean: false
- name: Install iai-callgrind-runner
run: ./.github/scripts/install_iai_callgrind_runner.sh
- name: Compare PR benchmarks
run: cargo bench -p revmc-cli --bench iai -- --baseline=$BASELINE
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ jobs:
- run: cargo doc --workspace --features ${{ env.ALL_BACKENDS }} --no-deps --document-private-items
env:
RUSTDOCFLAGS: --cfg docsrs -D warnings --show-type-layout --generate-link-to-definition --enable-index-page -Zunstable-options
# - name: Deploy documentation
# uses: peaceiris/actions-gh-pages@v3
# if: github.event_name == 'push' && github.ref == 'refs/heads/main'
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: target/doc
# force_orphan: true
- name: Deploy documentation
uses: peaceiris/actions-gh-pages@v3
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: target/doc
force_orphan: true

fmt:
runs-on: ubuntu-latest
Expand Down
36 changes: 19 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/revmc-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ tracing-tracy = { workspace = true, optional = true }

[dev-dependencies]
criterion = "0.5"
iai-callgrind = "0.11"
iai-callgrind = "0.14"
revmc-cli-tests = { path = "../revmc-cli-tests/" }

[build-dependencies]
Expand Down
43 changes: 21 additions & 22 deletions crates/revmc-cli/benches/iai.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
#![allow(missing_docs)]

use iai_callgrind::{
binary_benchmark_group, main, Arg, BinaryBenchmarkGroup, EventKind, FlamegraphConfig,
RegressionConfig, Run,
binary_benchmark_group, main, Bench, BinaryBenchmark, BinaryBenchmarkConfig,
BinaryBenchmarkGroup, Command, EventKind, FlamegraphConfig, RegressionConfig,
};

const CMD: &str = env!("CARGO_BIN_EXE_revmc-cli");

binary_benchmark_group!(
name = compile_time;
benchmark = |group: &mut BinaryBenchmarkGroup| setup_group(group, true)
name = revmc;
benchmarks = |group: &mut BinaryBenchmarkGroup| setup_group(group)
);

binary_benchmark_group!(
name = run_time;
benchmark = |group: &mut BinaryBenchmarkGroup| setup_group(group, false)
);

fn setup_group(group: &mut BinaryBenchmarkGroup, is_ct: bool) {
let make_run = |name: &str, small: bool| {
fn setup_group(group: &mut BinaryBenchmarkGroup) {
let make_bench = |name: &str, small: bool, is_ct: bool| {
let mut args = Vec::with_capacity(3);
args.push(name);
// let out_dir = std::env::temp_dir().join("revmc-cli-iai");
Expand All @@ -30,11 +25,11 @@ fn setup_group(group: &mut BinaryBenchmarkGroup, is_ct: bool) {
args.push("1");
// args.extend(["1", "--shared-library", so.to_str().unwrap()]);
}
let arg = Arg::new(name, args);
let mut run = Run::with_cmd(CMD, arg);
let mut bench = Bench::new(name);
bench.command(Command::new(CMD).args(&args)).config(BinaryBenchmarkConfig::default());

if !is_ct {
run.entry_point("*EvmCompilerFn::call*");
bench.config.as_mut().unwrap().entry_point = Some("*EvmCompilerFn::call*".into());
}

let mut regression = RegressionConfig::default();
Expand All @@ -44,15 +39,15 @@ fn setup_group(group: &mut BinaryBenchmarkGroup, is_ct: bool) {
} else {
regression.limits([(EventKind::EstimatedCycles, 5.0)]);
}
run.regression(regression);
bench.config.as_mut().unwrap().regression_config = Some(regression.into());

// Uses an insane amount of memory (???)
if cfg!(any()) && small && !is_ci() {
let flamegraph = FlamegraphConfig::default();
run.flamegraph(flamegraph);
bench.config.as_mut().unwrap().flamegraph_config = Some(flamegraph.into());
}

run
bench
};
let benches = [
("fibonacci", true),
Expand All @@ -65,16 +60,20 @@ fn setup_group(group: &mut BinaryBenchmarkGroup, is_ct: bool) {
// ("snailtracer", false),
// ("snailtracer-eof", false),
];
for (bench, small) in benches {
if !is_ct && !small {
continue;
for is_ct in [false, true] {
let mut bench = BinaryBenchmark::new(if is_ct { "compile_time" } else { "run_time" });
for (bench_name, small) in benches {
if !is_ct && !small {
continue;
}
bench.bench(make_bench(bench_name, small, is_ct));
}
group.bench(make_run(bench, small));
group.binary_benchmark(bench);
}
}

fn is_ci() -> bool {
std::env::var_os("CI").is_some()
}

main!(binary_benchmark_groups = compile_time, run_time);
main!(binary_benchmark_groups = revmc);

0 comments on commit 666f82a

Please sign in to comment.