Skip to content

Commit

Permalink
test: benchmark compilation (#2060)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien authored Oct 21, 2024
1 parent b98726e commit 15bc696
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions testing/integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ bls-signatures = { workspace = true }
hex = { workspace = true }
minstant = { workspace = true }
wat = "1.0.66"
criterion = { workspace = true }

[features]
default = []
m2-native = []
calibration = ["fvm/gas_calibration"]

[[bench]]
name = "compile"
harness = false
46 changes: 46 additions & 0 deletions testing/integration/benches/compile.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright 2021-2023 Protocol Labs
// SPDX-License-Identifier: Apache-2.0, MIT
use std::hint::black_box;
use std::time::Duration;

use cid::Cid;
use criterion::{criterion_group, criterion_main, Criterion};
use fvm::engine::EnginePool;
use fvm::machine::{Manifest, NetworkConfig};

use fvm_integration_tests::bundle;
use fvm_ipld_blockstore::MemoryBlockstore;
use fvm_ipld_encoding::CborStore;
use fvm_shared::version::NetworkVersion;

fn bench_compile(c: &mut Criterion) {
c.bench_function("bench actor compile", |b| {
let blockstore = MemoryBlockstore::default();
let bundle_cid = bundle::import_bundle(&blockstore, actors_v12::BUNDLE_CAR).unwrap();

let (manifest_version, manifest_cid): (u32, Cid) =
blockstore.get_cbor(&bundle_cid).unwrap().unwrap();
let manifest = Manifest::load(&blockstore, &manifest_cid, manifest_version).unwrap();
let nc = NetworkConfig::new(NetworkVersion::V21);
b.iter_batched(
|| EnginePool::new((&nc).into()).unwrap(),
|engine| {
black_box(
engine
.acquire()
.preload_all(&blockstore, manifest.builtin_actor_codes())
.unwrap(),
);
},
criterion::BatchSize::SmallInput,
)
});
}

criterion_group! {
name = benches;
config = Criterion::default().sample_size(10).measurement_time(Duration::from_secs(30));
targets = bench_compile
}

criterion_main!(benches);

0 comments on commit 15bc696

Please sign in to comment.