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

Let VM control when or if to read env var options #955

Merged
merged 2 commits into from
Sep 15, 2023

Conversation

wks
Copy link
Collaborator

@wks wks commented Sep 13, 2023

Allow Options to be created with MMTK's built-in defaults without reading options from environment variables, and let the VM decide when to read options from environment variables.

This will allow VMs to provide default options, override MMTK's default options, but can be overridden by environment variables. It will also allow VMs to completely disable the "MMTK_*" variables.

For compatibility reasons, this PR does not change the default behavior of MMTKBuilder. MMTKBuilder::new will still read from environment variables, but the new constructor MMTKBuilder::new_no_env_vars will skip environment variables.

Fixes: #636

Allow Options to be created with MMTK's built-in defaults without
reading options from environment variables, and let the VM decide when
to read options from environment variables.

This will allow VMs to provide default options, override MMTK's default
options, but can be overridden by environment variables.  It will also
allow VMs to completely disable the "MMTK_*" variables.

For compatibility reasons, this PR does not change the default behavior
of MMTKBuilder.  MMTKBuilder::new will still read from environment
variables, but the new constructor MMTKBuilder::new_no_env_vars will
skip environment variables.

Fixes: mmtk#636
// If we have env vars that start with MMTK_ and match any option (such as MMTK_STRESS_FACTOR),
// we set the option to its value (if it is a valid value). Otherwise, use the default value.
/// Create an `Options` instance with built-in default settings.
pub fn new() -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

The public API changes include this function.

Added items to the public API
=============================
+pub fn mmtk::util::options::Options::new() -> Self
+pub fn mmtk::util::options::Options::read_env_var_settings(&mut self)
+pub fn mmtk::MMTKBuilder::new_no_env_vars() -> Self

But this function does not need to public. The other two are fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done. I have made new() private.

Options still implements Default, so VMs can still instantiate it, although Options should usually be created by the MMTKBuilder.

Copy link
Member

Choose a reason for hiding this comment

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

We probably don't want VMs to create Options either (they should create a builder which will create Options inside mmtk-core). I guess it was clippy that complains about Default, so we added Default. Anyway, no action is needed for this PR.

Note that Options::default() is still public.
@qinsoon qinsoon added the PR-testing Run binding tests for the pull request (deprecated: use PR-extended-testing instead) label Sep 14, 2023
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.

LGTM

@wks wks added this pull request to the merge queue Sep 15, 2023
Merged via the queue into mmtk:master with commit 42f109b Sep 15, 2023
25 of 26 checks passed
@wks wks deleted the feature/no-env-var-opts branch September 15, 2023 07:47
wks added a commit to mmtk/mmtk-openjdk that referenced this pull request Sep 21, 2023
This PR lets MMTk-side Options read environment variables for options
after OpenJDK-side default options are applied. By doing this,
environment variables like MMTK_THREADS are no longer ignored.

Fixes: #242

This PR makes use of the change introduced in
mmtk/mmtk-core#955
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.

VM overriding default Options
3 participants