-
Notifications
You must be signed in to change notification settings - Fork 81
Introduce MockVM #1049
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
Merged
Merged
Introduce MockVM #1049
Changes from 10 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
dacfa5e
Introduce MockMethod and MockVM
qinsoon c153c7a
Move DummyVM tests to MockVM tests. WIP
qinsoon 0738220
All the tests
qinsoon dae2f6a
Move benches to the main crate
qinsoon 988548d
Remove examples and dummyvm. Minor fixes
qinsoon 29dcdc7
Move tests to vm/tests. Add some comments for MockVM.
qinsoon 1519a62
Fix doc. Move mock tests to a separate folder.
qinsoon f0df3af
Merge branch 'master' into mock-vm
qinsoon 1461664
Add back get_type_descriptor for this PR.
qinsoon a4403d1
cargo fmt
qinsoon 9fe32ee
Fix typo. More explanation on MockAny. Clippy check with mock_test
qinsoon c67aabb
clippy check for --tests and --benches
qinsoon 85227df
Add more comments when we create a MockMethod for MockAny
qinsoon 22cac3b
Fix broken link in user guide
qinsoon ca97792
Fix style check for the stable Rust toolchain
qinsoon 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
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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; | ||
| use criterion::Criterion; | ||
|
|
||
| use mmtk::memory_manager; | ||
| use mmtk::util::test_util::fixtures::*; | ||
| use mmtk::AllocationSemantics; | ||
|
|
||
| pub fn bench(c: &mut Criterion) { | ||
| // Disable GC so we won't trigger GC | ||
| let mut fixture = MutatorFixture::create_with_heapsize(1 << 30); | ||
| memory_manager::disable_collection(&mut fixture.mmtk()); | ||
| c.bench_function("alloc", |b| { | ||
| b.iter(|| { | ||
| let _addr = | ||
| memory_manager::alloc(&mut fixture.mutator, 8, 8, 0, AllocationSemantics::Default); | ||
| }) | ||
| }); | ||
| } | ||
This file contains hidden or 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,37 @@ | ||
| use criterion::criterion_group; | ||
| use criterion::criterion_main; | ||
| use criterion::Criterion; | ||
|
|
||
| // As we can only initialize one MMTk instance, we have to run each benchmark in a separate process. | ||
| // So we only register one benchmark to criterion ('bench_main'), and based on the env var MMTK_BENCH, | ||
| // we pick the right benchmark to run. | ||
|
|
||
| // The benchmark can be executed with the following command. The feature `mock_test` is required, as the tests use MockVM. | ||
| // MMTK_BENCH=alloc cargo bench --features mock_test | ||
| // MMTK_BENCH=sft cargo bench --features mock_test | ||
|
|
||
| // [Yi] I am not sure if these benchmarks are helpful any more after the MockVM refactoring. MockVM is really slow, as it | ||
| // is accessed with a lock, and it dispatches every call to function pointers in a struct. These tests may use MockVM, | ||
| // so they become slower as well. And the slowdown | ||
| // from MockVM may hide the actual performance difference when we change the functions that are benchmarked. | ||
| // We may want to improve the MockVM implementation so we can skip dispatching for benchmarking, or introduce another MockVM | ||
| // implementation for benchmarking. | ||
| // However, I will just keep these benchmarks here. If we find it not useful, and we do not plan to improve MockVM, we can delete | ||
| // them. | ||
|
|
||
| mod alloc; | ||
| mod sft; | ||
|
|
||
| fn bench_main(c: &mut Criterion) { | ||
| match std::env::var("MMTK_BENCH") { | ||
| Ok(bench) => match bench.as_str() { | ||
| "alloc" => alloc::bench(c), | ||
| "sft" => sft::bench(c), | ||
| _ => panic!("Unknown benchmark {:?}", bench), | ||
| }, | ||
| Err(_) => panic!("Need to name a benchmark by the env var MMTK_BENCH"), | ||
| } | ||
| } | ||
|
|
||
| criterion_group!(benches, bench_main); | ||
| criterion_main!(benches); |
This file contains hidden or 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; | ||
| use criterion::criterion_group; | ||
qinsoon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| use criterion::Criterion; | ||
|
|
||
| use mmtk::memory_manager; | ||
| use mmtk::util::test_util::fixtures::*; | ||
| use mmtk::util::test_util::mock_vm::*; | ||
| use mmtk::vm::ObjectModel; | ||
| use mmtk::vm::VMBinding; | ||
| use mmtk::AllocationSemantics; | ||
|
|
||
| pub fn bench(c: &mut Criterion) { | ||
| let mut fixture = MutatorFixture::create(); | ||
| let addr = memory_manager::alloc(&mut fixture.mutator, 8, 8, 0, AllocationSemantics::Default); | ||
| let obj = <MockVM as VMBinding>::VMObjectModel::address_to_ref(addr); | ||
|
|
||
| c.bench_function("sft read", |b| { | ||
| b.iter(|| memory_manager::is_in_mmtk_spaces::<MockVM>(black_box(obj))) | ||
| }); | ||
| } | ||
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.