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

Benchmark Rust code #933

Merged
merged 3 commits into from
Sep 4, 2023
Merged

Benchmark Rust code #933

merged 3 commits into from
Sep 4, 2023

Conversation

qinsoon
Copy link
Member

@qinsoon qinsoon commented Sep 1, 2023

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.

@qinsoon qinsoon marked this pull request as ready for review September 1, 2023 05:35
@qinsoon qinsoon requested a review from wks September 1, 2023 05:38
Copy link
Collaborator

@wks wks left a 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)))
Copy link
Collaborator

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.

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 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.

@qinsoon qinsoon added this pull request to the merge queue Sep 4, 2023
Merged via the queue into mmtk:master with commit aedb37a Sep 4, 2023
16 of 19 checks passed
@qinsoon qinsoon deleted the benchmark-rust-code branch September 4, 2023 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants