badass-jlink-plugin icon indicating copy to clipboard operation
badass-jlink-plugin copied to clipboard

Enhancement: AppCDS support

Open msgilligan opened this issue 4 years ago • 4 comments
trafficstars

After reading Smaller, Faster-starting Container Images With jlink and AppCDS I'm thinking it might be possible to achieve faster startup in jlinked/jpackaged apps using AppCDS.

Would it make sense to add this to badass-jlink-plugin?

msgilligan avatar Dec 15 '20 18:12 msgilligan

More info here: https://www.morling.dev/blog/building-class-data-sharing-archives-with-apache-maven/

It would probably make sense for there to be a separate Gradle plugin for AppCDS, but the badass-jink-plugin could have an option to apply it as part of the build process.

msgilligan avatar Dec 15 '20 18:12 msgilligan

It does not work with -module-path, and it requires Shadow jar. I've tried only with badass-runtime, works flawless. Everything can be easily done with exec task on Gradle, although some libs like okhttp3 requires full exclusion from classes.txt so there is user knowledge involved about what is cached. The other thing is that collection of classes is done while running JVM, which would add another complexity for on top of this Badass plugin. AppCDS concept is great, works fine with Java 11 and Javafx, i've got loading times halved in busy fx app.

norbert-gaulia avatar Dec 18 '20 08:12 norbert-gaulia

Since Java 11, CDS also supports --module-path.

I added experimental support for CDS in badass-jlink 2.23.0 and badass-runtime 1.12.0:

runtime {
    ...
    enableCds()
}

It requires Java 11+ in badass-jlink and Java 13+ in badass-runtime.

In the case of badass-runtime, the plugin does two things:

  • creates a base CDS archive of the image by executing java -Xshare:dump
  • configures the start scripts to either create a dynamic AppCDS archive (using the -XX:ArchiveClassesAtExit option) or to use the existing one (using -XX:SharedArchiveFile) (See the documentation for more details.)

In the case of badass-jlink, the situation is simpler: only the base CDS archive of the image is needed, because the modular application is also part of the custom runtime image.

I would love your feedback.

siordache avatar Dec 18 '20 18:12 siordache

Actually, a dynamic AppCDS archive also makes sense in the case of badass-jlink, when customImage is used. I added this in 2.23.1 (see the documentation).

siordache avatar Dec 21 '20 12:12 siordache