Reworking the options processing in OMR Compiler Technology has been a topic of discussion a number of times in the past. As an open source project, it is now more important than ever before to rework the options processing framework so that new developers find it easier to work with.
This issue will be used to track the progress and discussions surrounding this rework.
TR::Options does a lot more work than it is supposed to be doing. It involves command line parsing, trace and verbose log handling, option set and regex handling and many others that should really be split into other more specialized classes.TR_EnableFeatureX and TR_DisableFeatureX, we could perhaps do with one TR_FeatureX option.TR::Options.Below are some high-level descriptions of tasks to be completed to address each of the limitations of the current options processing framework. Proposals for addressing limitation 5, 6 and 7 will be made after we get to see the outcome of addressing limitation 1, 2 and 4 as it is too early to decide on a solution for them.
TR::Options into more specialized classes.TR_EnableFeatureX and TR_DisableFeatureX into one TR_FeatureX.The reworked options processing framework is going to be implemented in multiple phases to make the transition easier. In addition to linking the items below to their respective issues and PRs, this section will be expanded with further steps along the path towards an improved options processing framework after more discussions around the topic took place.
Reworking the options processing framework is going to affect most community members involved directly or indirectly with OMR Compiler Technology. Therefore, your input on the matter is very important. Feel free to talk about what you would or wouldn't want to see in the reworked options processing world. The input received within a week will be used to formulate the initial design. In the meantime, progress can be made with the first steps above to get the code into better shape.
Thanks for writing this up. Lots of good information here. The following are my initial thoughts:
TR_EnableFeatureX and TR_DisableFeatureX can still be folded into TR_FeatureX as this is a C++ entity, however the user should not lose the ability to supply disableFeatureX. It should just map down (alias) to whatever the new system is.TR_ prefix@fjeremic
Why and how much do we care about performance?
I think the main concern has to do with the performance of looking up whether an option has been enabled or not, as opposed to the performance of just parsing the options. Currently, this kind of lookup is done by checking whether a specific option bit is set, which is quite efficient. Ideally, the new option handling mechanism should support comparably efficient lookup.
Of course, the performance of actually parsing and processing the options is also important as it can affect start-up. However, as you pointed out, this should be fairly inexpensive and is less likely be problematic.
@fjeremic Thank you for sharing your thoughts about this.
Why and how much do we care about performance?
While the cost of processing options into the global Options and per-compilation Options may not affect overall performance too much, the cost of looking up options have to remain minimal due to how frequently options are queried at run-time. I believe the performance regression resulting from the rework can be measured by using existing benchmarking tools that are used for perf monitoring across different versions (please correct me if I have the wrong idea about it since I have not done this myself yet).
ability to alias option names
The ability to apply existing options correctly is a very important requirement and something I should have specified above. Thank you for bringing this up. When I was talking of merging TR_EnableFeatureX and TR_DisableFeatureX into TR_FeatureX, I was talking about how they would be stored in the new options/feature info containing structure, and not have users lose the ability to pass in -Xjit:disableFeatureX. The command line and environment options parser would take care of applying that appropriately by setting TR_FeatureX as off.
We should consider eliminating the TR_ prefix
I think eliminating TR_ prefix for options would make the option names shorter and slightly easier to work with. Some option names are very long, and the prefix just makes the problem worse (eg. TR_DisableReducedPriorityForCustomMethodHandleThunks). I am curious about why the option names have been prefixed with TR_ in the first place.
ability to provide/print help documentation for a particular option
I think that can be added as another limitation of the current options processing framework, or perhaps limitation 7 could be reworded with this limitation added. This would definitely be very useful. How do you envision such a feature implemented and used? An example of such an implementation I can think of right now: some projects take an option like -h<option-name> in the CLI and that outputs the help text related to the option, as well as the possible values.
I am curious about why the option names have been prefixed with
TR_in the first place.
Before being contributed to the Eclipse Foundation as part of OMR, the compiler had an internal name of Testarossa.[1] Because historically the compiler had not used namespaces, to prevent symbol identifier collisions, every symbol introduced by the compiler was prefixed with TR_ as a sort-of poor-man's equivalent.
[1] https://www.slideshare.net/MarkStoodley/under-the-hood-of-the-testarossa-jit-compiler
We should use proper namespaces now that they're supported and encouraged. Thanks for the reference @lmaisons! Looking forward to the talk later today.
Is there any reason this has to be a compiler-specific discussion, other than the fact that it's the original compiler options facility that we're looking to replace?
Is there any reason OMR couldn't have a single options processing strategy and implementation? Are there any additional requirements that other components would add into the discussion for the new options framework to handle? @charliegracie @DanHeidinga .
I can understand this kind of broadening activity complicates things, but I would have expected the JIT to have the most complex requirements for options processing so hopefully it won't stretch the goals too much further (he said, naively). I just want to make sure we don't miss something that other components need but wouldn't be surfaced by focusing solely on the compiler component's needs/goals.
I think it would be a shame to spend all this time redesigning such a fundamental part of the compiler only to end up implementing not quite a single options processing framework for OMR.
We have had success separating other parts of the compiler into independent entities that could be consumed by other projects or even other parts of OMR itself (e.g., limitfile processing and debug counters [tragically not contributed, but at least it demonstrates it is possible]). Options processing and feature detection could be architected with that goal in mind as well. They are just another tool in the OMR toolbox. Inputs to this design are welcome from anywhere.
Not limited to Options processing, but we should be striving for greater sharing and a more seamless look-and-feel to all the components of OMR.
Most helpful comment
Is there any reason this has to be a compiler-specific discussion, other than the fact that it's the original compiler options facility that we're looking to replace?
Is there any reason OMR couldn't have a single options processing strategy and implementation? Are there any additional requirements that other components would add into the discussion for the new options framework to handle? @charliegracie @DanHeidinga .
I can understand this kind of broadening activity complicates things, but I would have expected the JIT to have the most complex requirements for options processing so hopefully it won't stretch the goals too much further (he said, naively). I just want to make sure we don't miss something that other components need but wouldn't be surfaced by focusing solely on the compiler component's needs/goals.
I think it would be a shame to spend all this time redesigning such a fundamental part of the compiler only to end up implementing not quite a single options processing framework for OMR.