-
Notifications
You must be signed in to change notification settings - Fork 80
Description
The VM may want to provide a different set of default values for MMTk options than those defined in src/util/options.rs. For example,
- In
mmtk-core, the defaultplanisNoGC, and the defaultheap_sizeis512MiB50% of the physical memory. - The Ruby binding wants to set the default plan to
MarkSweep, and the defaultheap_sizeto80% the physical memory(since the GCTrigger feature is available) dynamically resizing between 1MiB to 80% of the physical memory.
But the Ruby binding still allows the user to set those options via command line options or environment variables. For example,
- If the user specified
--mmtk-plan=Immixor set env varMMTK_PLAN=Immix, MMTk should use the Immix plan; and - if the user specified
--mmtk-max-heap=16MiBor set env varTHIRD_PARTY_HEAP_LIMIT=16777216, the heap size should be 16MiB.
So we shall have the following 4 ways to set MMTK options, with increasing priorities:
mmtk-core defaults < Ruby defaults < environment variables < command line arguments
The current MMTk core does not allow us to put Ruby defaults between mmtk-core defaults and environment variables, because when the Options struct is created using Options::default(), it populates the instance with mmtk-core defaults, and immediately look for environment variables, leaving no time in between.
One way to solve this problem is provide two methods:
- One method creates an
Optionsstruct, and populates it with the default values defined insrc/util/options.rs, and - The other method, possibly an instance method on
Options, appliesMMTK_*env vars to theOptionsinstance.
By doing this, Ruby can inject its own defaults between (1) and (2).
Example
Let's use Ruby as an example. Ruby wants to override the default plan and the default gc trigger to dynamic resizing. The mmtk-ruby binding should do the following:
- The mmtk-ruby binding instantiates an
mmtk::util::Optionsstructure filled with default values. - The mmtk-ruby binding overrides the default values:
- sets
Options::plantoMarkSweep, and - sets
Option::gc_triggertoDynamic
- sets
- The mmtk-ruby calls a function provided by mmtk-core (for example,
Options::parse_from_env_var) to parse environment variables and update the fields ofOptions- For example, if the env var
MMTK_PLAN=Immixis set, it changesOptions::planto Immix; if not, it remains to beMarkSweep.
- For example, if the env var
- The mmtk-ruby parses its own command line arguments and sets options
- For example, if the user added
--mmtk-plan=Immixto the command line, it sets the plan to Immix; otherwise the plan remains what's set by the env var (if exists) or the default value.
- For example, if the user added
- The mmtk-ruby instantiates
MMTKusing theOptionsinstance.