Skip to content

Implement AppCDS support for startup time improvement #5069

Closed
@headius

Description

@headius

I have been playing with the new Application Class Data Sharing ("AppCDS") feature of Oracle's JDK, and the results have been good.

Combining AppCDS with our own flags (tier 1, no JRuby JIT) I get the following improvements:

  • -e 1 goes from 1.5s to 1.1s
  • -S gem list goes from 2.5s to 1.9s

This may see an even bigger improvement on platforms with notoriously bad startup time, like Linux.

Given these numbers, I think we should move forward with implementing AppCDS support in our launchers.

My current vision is as follows:

  • The launchers will check on startup for an existing CDS cache. If present, it will be used.
  • If not present, the launchers will generate a new cache. This would be localized into the JRuby install dir, probably somewhere in lib. It would likely need to be localized per OpenJDK/OracleJDK version, since the cache format makes no binary compat guarantees.
  • All subsequent runs that can detect the CDS cache and proper JDK version will boot up using the cache.

This would not be difficult to add to the bash script, and would only take a bit more work to add it to the native launcher.

I used the following instructions to generate an AppCDS cache specific to JRuby: https://github.com/kkinnear/zprint/blob/master/doc/filter.md#the-manual-way

Here's my session, showing all flags for dumping and using a CDS cache:

[] ~/projects/jruby $ export GENERATE_CLASSLIST='-XX:+UnlockCommercialFeatures -XX:+UseAppCDS -Xshare:off -XX:DumpLoadedClassList=jruby.classlist'

[] ~/projects/jruby $ export GENERATE_CDS='-XX:+UnlockCommercialFeatures -XX:+UseAppCDS -Xshare:dump -XX:SharedClassListFile=jruby.classlist -XX:SharedArchiveFile=jruby.cache'

[] ~/projects/jruby $ export USE_CDS='-XX:+UnlockCommercialFeatures -XX:+UseAppCDS -Xshare:on -XX:SharedArchiveFile=jruby.cache'

[] ~/projects/jruby $ time jruby --dev -e 1

real	0m1.440s
user	0m1.951s
sys	0m0.180s

[] ~/projects/jruby $ export VERIFY_JRUBY=1 # move JRuby to normal classpath for CDS

[] ~/projects/jruby $ JAVA_OPTS=$GENERATE_CLASSLIST jruby --dev -e 1

[] ~/projects/jruby $ JAVA_OPTS=$GENERATE_CDS jruby --dev -e 1
Allocated shared space: 314572800 bytes at 0x0000000800000000
Loading classes to share ...
...

[] ~/projects/jruby $ JAVA_OPTS=$USE_CDS time jruby --dev -e 1
        1.18 real         1.67 user         0.18 sys

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions