-
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
Let VM control when or if to read env var options #955
Conversation
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
src/util/options.rs
Outdated
// 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 { |
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.
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.
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.
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
.
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.
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.
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
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
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