Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an actor compilation benchmark #2060

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I think this benchmark is correct but... I'm not able to reproduce #2058.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be that the slowdown occurs under specific actor version(s)?

Copy link
Contributor

@LesnyRumcajs LesnyRumcajs Oct 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also didn't manage to reproduce it with this benchmark on a machine that showed a significant slowdown (used this benchmark on this branch and tag fvm@v4.3.3

bench actor compile     time:   [3.5975 s 3.6164 s 3.6374 s]
                        change: [-2.3529% -1.6171% -0.8734%] (p = 0.00 < 0.05)
                        Change within noise threshold.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be different versions. IIRC, we used to compile the actors optimizing for size instead of speed so that could be causing cranelift to take longer. I'll try pulling a specific version.

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);
Loading