-
Notifications
You must be signed in to change notification settings - Fork 69
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
Benchmark Rust code #933
Benchmark Rust code #933
Conversation
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.
LGTM.
In the future, we can add more test cases (for example, allocating objects of other sizes, and accessing the SFT in a random order) if this skeleton works.
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))) |
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.
This test is accessing the SFT entry of the same object again and again. The cache will always hit in this case. I recommend adding a test case where we access the SFT randomly. To make the performance comparison fair and stable, we can use a pseudo random number generator so that we always access the objects in the same "random" order.
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 is possible. We could control what we want to benchmark. criterion
provides an approach that allows us to microbenchmark short running functions. It is useful when we can isolate one function and check the performance of the function so that we can make changes to it with more confidence. It is a complement to what we usually do for benchmarking.
Though we can control what we want to benchmark, I am not convinced if we would like to use micro benchmarks to mimic a real situation. Using a larger benchmark or real workload is usually a better option.
Also for this case, I don't think we want to take cache locality into consideration. For SFT access, I would like to measure the performance impact of the code change for #931. Cache locality is not what I am trying to measure, and randomly accessing memory would just add more noise to the result.
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.