You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Storing all classes to SCC for startup performance #19323
Currently OpenJ9 stores only bootstrap classes and hidden(anon) classes in the SCC by default (i.e -Xshareclasses is not specified). As the hidden classes are not from the class path, they are returned by the SCC to the JVM via byte-to-byte comparison, so that we could still benefit from AOT on these classes.
When -Xshareclasses is specified, currently only class loader which implements the OpenJ9's public SCC APIs (and its child class loaders) can store classes to SCC. For custom class loaders that do not implement SCC APIs, SCC won't have the class path information so that we don't know where the class is from. These class are not stored to SCC now.
Similar to hidden(anon) classes, we can store these classes as orphan in the SCC and return via byte-to-byte comparison. If the benefit of AOT outweighs the cost of byte-to-byte comparison, we could still get startup performance improvements.
I've created a prototype that stores all classes to SCC (classes with no class path info are stored as orphan and returned via byte-to-byte comparison). @mpirvu has done some performance testing on this.
I performed some JBoss + AcmeAir start-up experiments (using Java17) with code from this PR and found that:
The prototype significantly increases the number of caches classes from 3340 to 18875,
The prototype increases the number of AOT compilations from 3250 to 5639
The prototype improves start-up time by 8-11% (depending on the configuration) mostly due to extra AOT compilations
There is no performance difference if I run with "-Xint" or with "-Xnoaot + specified counts"
To summarize, the prototype does not show any extra overhead due to different processing of classes, while it can improve start-up time due to extra AOT that can be generated.
I plan to add this feature in 0.46, but not turn it on by default immediately. Users willing to try this feature can turn it on using a command line option. It also gives us some time to gather feedback (if any) from users. If any unexpected issues (likely perf related) are observed, it won't impact all of our users. If everything goes well, we can consider turning it on by default after one more release (0.47+).
Are there more performance testing results on other applications ?
I tried "maven compile" for compiling Hadoop, but that is not a good application, since the vast majority of the classes alraedy get stored in the SCC withoout the prototype. Time permitting I will try other applications as well.
One thing I observed is that, when the implicit SCC is used (no -Xshareclasses option on the command line), the prototype will store non-bootstrap classes into the SCC. I thought that the implicit SCC was dedicated to non-bootstrap classes. We may want to amend the code in this respect.
Another thing to keep in mind: with the prototype, the CPU consumed by compilation threads increases because the JIT compiles more methods. This is due to to a heuristic that sets higher counts (3000/3000) for methods whose class is not in SCC. Since the prototype caches more classes in SCC, more methods will have a lower count (1000/250) and this will result in more methods being compiled. This is why, the relative advantage of the prototype decreases when we have fewer CPUs. With more CPUs, the compilation threads can compile those additional methods in parallel with the application threads, while with fewer CPUs, extra compilation activity will hinder application threads.
One thing I observed is that, when the implicit SCC is used (no -Xshareclasses option on the command line), the prototype will store non-bootstrap classes into the SCC. I thought that the implicit SCC was dedicated to non-bootstrap classes. We may want to amend the code in this respect.
Yes, that is the behaviour of the prototype. When preparing the prototype, I was expecting the experiments to be done using -Xshareclasses option. It will be addressed when I make the formal change to OpenJ9.
Yes I was thinking that Peter was suggesting what he has clarified, i.e. get some more internal testing with it enabled but only enable under -Xshareclasses externally at the next release. I would like to also get @mpirvu opinion before we did something like this (in addition to Hang's opinion obviously).
I was thinking more along the lines of enable it now to flush out problems, and perhaps reverse before we ship the release.
Ah, I see.
One more thing occurs to me is that as -XX:+ShareOrphans automatically turns on -Xshareclasses, it makes more sense to add the new options as -Xshareclasses: suboptions rather than -XX options.
Re-opening this as there are on-going discussions.
it makes more sense to add the new options as -Xshareclasses: suboptions
I'm not sure. We only support the last -Xshareclasses: option, while using -XX lets you turn it on/off without worried about -Xshareclasses suboptions.
Yes I was thinking that Peter was suggesting what he has clarified, i.e. get some more internal testing with it enabled but only enable under -Xshareclasses externally at the next release. I would like to also get @mpirvu opinion before we did something like this
@mpirvu Any comments on this (turning on this feature automatically by option -Xshareclasses in the master branch) ?
I will do some start-up experiments with a dev driver. Just to confirm, to enable the new code all I have to do is to add -XX:+ShareOrphans on the command line.
There is no DT8 start-up time or footprint regression from adding -XX:+ShareOrphans to the command line. If anything there is a 1% improvement, but that is probably noise.
Given this, we can enable -XX:+ShareOrphans when -Xshareclasses is specified.
Activity
hangshao0 commentedon Apr 15, 2024
@vijaysun-omr @mpirvu @TobiAjila @pshipton
hangshao0 commentedon Apr 15, 2024
I've created a prototype that stores all classes to SCC (classes with no class path info are stored as orphan and returned via byte-to-byte comparison). @mpirvu has done some performance testing on this.
mpirvu commentedon Apr 16, 2024
I performed some JBoss + AcmeAir start-up experiments (using Java17) with code from this PR and found that:
To summarize, the prototype does not show any extra overhead due to different processing of classes, while it can improve start-up time due to extra AOT that can be generated.
hangshao0 commentedon Apr 19, 2024
@mpirvu Thanks for providing the above results. Are there more performance testing results on other applications ?
hangshao0 commentedon Apr 25, 2024
I plan to add this feature in 0.46, but not turn it on by default immediately. Users willing to try this feature can turn it on using a command line option. It also gives us some time to gather feedback (if any) from users. If any unexpected issues (likely perf related) are observed, it won't impact all of our users. If everything goes well, we can consider turning it on by default after one more release (0.47+).
mpirvu commentedon Apr 25, 2024
I tried "maven compile" for compiling Hadoop, but that is not a good application, since the vast majority of the classes alraedy get stored in the SCC withoout the prototype. Time permitting I will try other applications as well.
One thing I observed is that, when the implicit SCC is used (no -Xshareclasses option on the command line), the prototype will store non-bootstrap classes into the SCC. I thought that the implicit SCC was dedicated to non-bootstrap classes. We may want to amend the code in this respect.
Another thing to keep in mind: with the prototype, the CPU consumed by compilation threads increases because the JIT compiles more methods. This is due to to a heuristic that sets higher counts (3000/3000) for methods whose class is not in SCC. Since the prototype caches more classes in SCC, more methods will have a lower count (1000/250) and this will result in more methods being compiled. This is why, the relative advantage of the prototype decreases when we have fewer CPUs. With more CPUs, the compilation threads can compile those additional methods in parallel with the application threads, while with fewer CPUs, extra compilation activity will hinder application threads.
hangshao0 commentedon Apr 25, 2024
Yes, that is the behaviour of the prototype. When preparing the prototype, I was expecting the experiments to be done using
-Xshareclassesoption. It will be addressed when I make the formal change to OpenJ9.18 remaining items
pshipton commentedon May 10, 2024
We can have it enabled in the head stream, and reverse in the release branches if necessary.
vijaysun-omr commentedon May 10, 2024
Yes I was thinking that Peter was suggesting what he has clarified, i.e. get some more internal testing with it enabled but only enable under
-Xshareclassesexternally at the next release. I would like to also get @mpirvu opinion before we did something like this (in addition to Hang's opinion obviously).hangshao0 commentedon May 10, 2024
Ah, I see.
One more thing occurs to me is that as
-XX:+ShareOrphansautomatically turns on-Xshareclasses, it makes more sense to add the new options as-Xshareclasses:suboptions rather than -XX options.Re-opening this as there are on-going discussions.
pshipton commentedon May 10, 2024
I'm not sure. We only support the last -Xshareclasses: option, while using -XX lets you turn it on/off without worried about -Xshareclasses suboptions.
hangshao0 commentedon Jun 6, 2024
@mpirvu Any comments on this (turning on this feature automatically by option
-Xshareclassesin the master branch) ?mpirvu commentedon Jun 6, 2024
I will do some start-up experiments with a dev driver. Just to confirm, to enable the new code all I have to do is to add
-XX:+ShareOrphanson the command line.hangshao0 commentedon Jun 6, 2024
Yes. It is worth mentioning that option
-XX:+ShareOrphansalso turns on-Xshareclasses.mpirvu commentedon Jun 7, 2024
There is no DT8 start-up time or footprint regression from adding
-XX:+ShareOrphansto the command line. If anything there is a 1% improvement, but that is probably noise.Given this, we can enable
-XX:+ShareOrphanswhen-Xshareclassesis specified.Make option -Xshareclasses enable -XX:+ShareOrphans
Make option -Xshareclasses enable -XX:+ShareOrphans