-
Notifications
You must be signed in to change notification settings - Fork 137
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.