Skip to content

Storing all classes to SCC for startup performance #19323

Description

@hangshao0

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.

Activity

  1. hangshao0 commented on Apr 15, 2024

    @hangshao0
    ContributorAuthor
  2. hangshao0 commented on Apr 15, 2024

    @hangshao0
    ContributorAuthor

    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.

  3. mpirvu commented on Apr 16, 2024

    @mpirvu
    Contributor

    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.

  4. hangshao0 commented on Apr 19, 2024

    @hangshao0
    ContributorAuthor

    @mpirvu Thanks for providing the above results. Are there more performance testing results on other applications ?

  5. hangshao0 commented on Apr 25, 2024

    @hangshao0
    ContributorAuthor

    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+).

  6. mpirvu commented on Apr 25, 2024

    @mpirvu
    Contributor

    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.

  7. hangshao0 commented on Apr 25, 2024

    @hangshao0
    ContributorAuthor

    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.

  8. 18 remaining items

  9. pshipton commented on May 10, 2024

    @pshipton
    Member

    We can have it enabled in the head stream, and reverse in the release branches if necessary.

  10. vijaysun-omr commented on May 10, 2024

    @vijaysun-omr
    Contributor

    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).

  11. hangshao0 commented on May 10, 2024

    @hangshao0
    ContributorAuthor

    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.

  12. pshipton commented on May 10, 2024

    @pshipton
    Member

    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.

  13. hangshao0 commented on Jun 6, 2024

    @hangshao0
    ContributorAuthor

    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) ?

  14. mpirvu commented on Jun 6, 2024

    @mpirvu
    Contributor

    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.

  15. hangshao0 commented on Jun 6, 2024

    @hangshao0
    ContributorAuthor

    to enable the new code all I have to do is to add -XX:+ShareOrphans on the command line.

    Yes. It is worth mentioning that option -XX:+ShareOrphans also turns on -Xshareclasses.

  16. mpirvu commented on Jun 7, 2024

    @mpirvu
    Contributor

    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.

  17. added a commit that references this issue on Jun 11, 2024
    526beb0
  18. added a commit that references this issue on Jun 28, 2024
    a4711b4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions