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

Boot-time configurable heap constants #899

Merged
merged 59 commits into from
Aug 24, 2023
Merged

Conversation

wenyuzhao
Copy link
Member

@wenyuzhao wenyuzhao commented Aug 14, 2023

This CL refactors the vm_layout_constants related code and changes all the related compile-time constants to run-time constants, so that VM bindings can configure them during boot time based on dynamic user inputs.

This is a necessary refactoring to support compressed pointers. For most of the VMs (e.g. OpenJDK), compressed pointers are enabled at run-time based on command line arguments, and VM bindings should be able to enable compressed pointer heap dynamically during the VM boot process. Such a process usually involves dynamically configuring heap ranges, space memory layout, and choosing a different VMMap implementation [1]. Thus all vm_layout_constants, including heap constants, should be made as boot-time configurable, instead of compile-time constants.

This CL also makes risc-v's 39-bit heap support easier, as it now should only involve adding a new set of vm_layout_constants.

[1] This is already done by #732


Benchmark results: Almost no performance impact

http://squirrel.anu.edu.au/plotty-public/wenyuz/v8/p/NkK9YG

@wenyuzhao wenyuzhao requested review from qinsoon and caizixian August 14, 2023 04:52
@caizixian caizixian added the PR-testing Run binding tests for the pull request (deprecated: use PR-extended-testing instead) label Aug 14, 2023
@caizixian
Copy link
Member

@wenyuzhao can you suppress some warnings on x86?

@caizixian
Copy link
Member

V8 binding tests will fail until #472 is merged

@qinsoon
Copy link
Member

qinsoon commented Aug 14, 2023

Can you run performance tests for the PR?

I am wondering if we would need a feature like runtime_vm_layout. Without the feature, we can just have a const VMLayoutConstants.

@wenyuzhao
Copy link
Member Author

Can you run performance tests for the PR?

will do

I am wondering if we would need a feature like runtime_vm_layout. Without the feature, we can just have a const VMLayoutConstants.

Yes, this is possible. Let's wait for the performance test results and see if it is worth doing so.

@qinsoon qinsoon removed the PR-testing Run binding tests for the pull request (deprecated: use PR-extended-testing instead) label Aug 22, 2023
@qinsoon
Copy link
Member

qinsoon commented Aug 22, 2023

I suggest adding some tests that only run on 64 bits architecture in DummyVM (vmbindings/dummyvm/src/tests): set a custom VM layout for the compressed pointer layout, initialize MMTk, create a mutator, and finish one allocation. The test should run for all plans (Add // GITHUB-CI: MMTK_PLAN=all at the top of the test file)

I added some tests for VMLayout. Some are failing. Feel free to modify the tests if they are wrong, or ignore some tests. I just added the tests to see what is working, and what is not.

src/mmtk.rs Outdated Show resolved Hide resolved
@wenyuzhao
Copy link
Member Author

I suggest adding some tests that only run on 64 bits architecture in DummyVM (vmbindings/dummyvm/src/tests): set a custom VM layout for the compressed pointer layout, initialize MMTk, create a mutator, and finish one allocation. The test should run for all plans (Add // GITHUB-CI: MMTK_PLAN=all at the top of the test file)

I added some tests for VMLayout. Some are failing. Feel free to modify the tests if they are wrong, or ignore some tests. I just added the tests to see what is working, and what is not.

Interesting. I can't even pass all the dummyvm tests on the master branch

https://gist.github.com/wenyuzhao/ed9614dfec7b1fdac7bee8664b547e46

Is MMTK_PLAN=NoGC cargo test the correct command to run dummyvm tests?

@qinsoon
Copy link
Member

qinsoon commented Aug 22, 2023

I suggest adding some tests that only run on 64 bits architecture in DummyVM (vmbindings/dummyvm/src/tests): set a custom VM layout for the compressed pointer layout, initialize MMTk, create a mutator, and finish one allocation. The test should run for all plans (Add // GITHUB-CI: MMTK_PLAN=all at the top of the test file)

I added some tests for VMLayout. Some are failing. Feel free to modify the tests if they are wrong, or ignore some tests. I just added the tests to see what is working, and what is not.

Interesting. I can't even pass all the dummyvm tests on the master branch

https://gist.github.com/wenyuzhao/ed9614dfec7b1fdac7bee8664b547e46

Is MMTK_PLAN=NoGC cargo test the correct command to run dummyvm tests?

No. Each test module (file) is executed separately:

// NOTE: Since the dummyvm uses a global MMTK instance,

You can do MMTK_PLAN=NoGC cargo test --features features_you_need -- test_module_name

@qinsoon
Copy link
Member

qinsoon commented Aug 23, 2023

Maybe try a different heap layout for the failing test on macos, or simply ignore that test on macOS. I think either is okay.

@caizixian
Copy link
Member

The address is too low for 64-bit macOS https://stackoverflow.com/questions/46916112/osx-ld-why-does-pagezero-size-default-to-4gb-on-64b-osx

@wenyuzhao
Copy link
Member Author

Maybe try a different heap layout for the failing test on macos, or simply ignore that test on macOS. I think either is okay.

Switched to a different address on macos. Now all the checks are passed.

Copy link
Member

@qinsoon qinsoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks for the PR. Let's merge this after the current release (0.19) which should be done today.

@qinsoon qinsoon added the PR-testing Run binding tests for the pull request (deprecated: use PR-extended-testing instead) label Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-testing Run binding tests for the pull request (deprecated: use PR-extended-testing instead)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants