-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR allows benchmarking mmtk-core code in DummyVM. It uses `criterion`, which is a popular framework to benchmark with a stable Rust toolchain. This PR just introduces code and two benchmarks that specifically test our allocation code in Rust and our SFT read access. This PR does not include those benchmarks in the CI.
- Loading branch information
Showing
15 changed files
with
97 additions
and
13 deletions.
There are no files selected for viewing
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,18 @@ | ||
use criterion::{criterion_group, Criterion}; | ||
|
||
use mmtk::plan::AllocationSemantics; | ||
use mmtk_dummyvm::api; | ||
use mmtk_dummyvm::test_fixtures::MutatorFixture; | ||
|
||
fn alloc(c: &mut Criterion) { | ||
println!("Init MMTK in alloc bench"); | ||
// 1GB so we are unlikely to OOM | ||
let fixture = MutatorFixture::create_with_heapsize(1 << 30); | ||
c.bench_function("alloc", |b| { | ||
b.iter(|| { | ||
let _addr = api::mmtk_alloc(fixture.mutator, 8, 8, 0, AllocationSemantics::Default); | ||
}) | ||
}); | ||
} | ||
|
||
criterion_group!(benches, alloc); |
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,20 @@ | ||
use criterion::{black_box, criterion_group, Criterion}; | ||
|
||
use mmtk::plan::AllocationSemantics; | ||
use mmtk::vm::ObjectModel; | ||
use mmtk_dummyvm::api; | ||
use mmtk_dummyvm::test_fixtures::FixtureContent; | ||
use mmtk_dummyvm::test_fixtures::MutatorFixture; | ||
|
||
fn sft(c: &mut Criterion) { | ||
println!("Init MMTK in sft bench"); | ||
let fixture = MutatorFixture::create(); | ||
let addr = api::mmtk_alloc(fixture.mutator, 8, 8, 0, AllocationSemantics::Default); | ||
let obj = mmtk_dummyvm::object_model::VMObjectModel::address_to_ref(addr); | ||
|
||
c.bench_function("sft read", |b| { | ||
b.iter(|| api::mmtk_is_in_mmtk_spaces(black_box(obj))) | ||
}); | ||
} | ||
|
||
criterion_group!(benches, sft); |
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,15 @@ | ||
use criterion::criterion_main; | ||
|
||
// As we can only initialize one MMTk instance, we have to run each benchmark separately. | ||
// Filtering like `cargo bench -- sft` won't work, as it still evalutes all the benchmark groups (which initialize MMTk). | ||
// We can use conditional compilation, and run with `cargo bench --features bench_sft`. The features are defined in the dummy VM crate. | ||
|
||
#[cfg(feature = "bench_sft")] | ||
mod bench_sft; | ||
#[cfg(feature = "bench_sft")] | ||
criterion_main!(bench_sft::benches); | ||
|
||
#[cfg(feature = "bench_alloc")] | ||
mod bench_alloc; | ||
#[cfg(feature = "bench_alloc")] | ||
criterion_main!(bench_alloc::benches); |
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
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
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
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
2 changes: 1 addition & 1 deletion
2
vmbindings/dummyvm/src/tests/issue867_allocate_unrealistically_large_object.rs
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
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