Closed hangshao0 closed 2 weeks ago
@hangshao0 - What was the problem because of which this new option had to be added?
It's not a fix for a problem, it's a new feature which may result in better startup performance, as per https://github.com/eclipse-openj9/openj9/issues/19323 By storing additional classes in the cache, AOT can be created and used on these classes, which may result in better startup performance.
There is a known problem with using the option, fixed via https://github.com/eclipse-openj9/openj9/pull/19833. We should consider holding back the documentation until 0.47 which includes the fix, or mention the problem in the release notes. @hangshao0 what is your preference?
We could mention the problem in the release notes.
Updated the Restrictions
section with known problems.
We could mention the problem in the release notes.
@pshipton @hangshao0 - So that means I should document this new option but mention the problem in the Release notes, isn't it?
So that means I should document this new option but mention the problem in the Release notes, isn't it?
Yes.
@hangshao0 - Could you please check the following content and let me know if any changes should be made. Thanks!
This option enables or disables sharing of orphan class from class loader that is unaware of the OpenJ9 shared class API.
-XX:[+|-]ShareOrphans
Setting | Effect | Default |
---|---|---|
-XX:+ShareOrphans |
Enable | |
-XX:-ShareOrphans |
Disable | :fontawesome-solid-check:{: .yes aria-hidden="true"}yes |
In the previous versions, OpenJ9 stored only bootstrap classes and hidden classes in the shared classes cache by default, that is -Xshareclasses
is not specified by default. When -Xshareclasses
was specified, only those class loaders that implemented the OpenJ9's public shared classes cache APIs (and its child class loaders) could store classes to the shared classes cache. Classes from custom class loaders that did not implement shared classes cache APIs has no class path information. Because the shared classes cache didn't have the class path information, these classes were not stored to the shared classes cache.
You can enable class sharing from all class loaders, irrespective of whether the class loader implements the OpenJ9's public shared classes cache API, with the -XX:+ShareOrphans
option. This option automatically turns on -Xshareclasses
. When the class sharing from all class loaders is enabled, the following is the sharing behavior:
For classes from class loaders that implement the OpenJ9 shared class API, they are shared as normal rom classes, which is same as turning on -Xshareclasses
.
For classes from class loaders that do not implement the OpenJ9 shared class API, the VM won't have their class or module path information. They are shared as orphan rom classes with other VMs after extra comparisons.
Storing additional classes in the cache makes more classes available for Ahead-of-Time (AOT) compilation and therefore might improve startup performance.
You can disable sharing class as orphans from class loader that does not implement the OpenJ9 shared class API with the -XX:-ShareOrphans
option. This option is the default mode.
:fontawesome-solid-triangle-exclamation:{: .warn aria-hidden="true"} Restrictions:
java.lang.StackTraceElement.getClassLoaderName()
might return null for classes that are stored in the shared cache.Classes from custom class loaders that did not implement shared classes cache APIs has no class path information. Because the shared classes cache didn't have the class path information, these classes were not stored to the shared classes cache.
"Classes from custom class loaders ... has no class path information". These classes do have class path information, it is just the JVM does not know such information (The class loader does not implement the shared class cache APIs to pass such info to the JVM). It is better to say sth like "For classes from custom class loaders that did not implement shared classes cache APIs, JVM does not have their module path or class path information and they were not stored to the shared classes cache."
the benefits of more AOT generated for the cached class offset the negative impact. More cached classes result in more AOT-compiled methods.
This feature makes more classes available for AOT compilation. The final result might vary depending on the applications. So it is better to say sth like "could offset the negative impact", "usually result in more AOT-compiled methods"
Issue or pull request number: issue: https://github.com/eclipse-openj9/openj9/issues/19323 PR: https://github.com/eclipse-openj9/openj9/pull/19442
Overview: New -XX command line options to control classes sharing from all class loaders.
Release target: Eclipse OpenJ9 0.46.0
Applies to the following JDK versions: All versions
Applies to the following platforms: All platforms
For new command line options:
Option name and syntax:
-XX:+ShareOrphans
Enable class sharing from all class loaders. This option automatically turns on -Xshareclasses.-XX:-ShareOrphans
Disable sharing class as orphans from class loader which is unaware of the OpenJ9 shared class API. This is the default mode.java.lang.StackTraceElement.getClassLoaderName()
could return null for classes stored in the shared cache. (Known problems iii and iv are fixed in 0.47)