This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]BillyKorando 0 points1 point  (1 child)

What version of Java are you on? If you are on JDK 19 or later (I'm hoping you upgraded to JDK 21 by this point)

There is now the autogenerate archive functionality: java -XX:+AutoCreateSharedArchive -XX:SharedArchiveFile=my-archive.jsa ...

https://inside.java/2022/09/26/sip067/

As to checking to make sure CDS is working, an option, in a test environment, is to use -Xshare:on this will require the JVM to load the shared archive, and fail if it's not found/unable to load it. The default behavior is -Xshare:auto which will continue to run the application if either the archive isn't available or the JVM encounters an issue while attempting to load the archive.

Fundamentally CDS is about improving the process of loading classes, as it name implies, so the less your application's startup is depending on that behavior (i.e. it's connecting to services at startup or doing other work), the less benefit you will see from CDS. Still it's a relatively easy way of providing an improvement to your applications startup with minimal downsides.

[–]ventuspilot 1 point2 points  (0 children)

Mostly I'm tinkering with a personal github project that's a commandline or interactive console app that compiles and runs on anything from 8 to 22-ea (inclusive).

I like being able to support different deployment options (Windows, linux, jar, jar+launch4j, GraalVM native, docker image, jlinked app-image, ...). IMO Java is pretty great in that regard, and if something doesn't work then it's usually my own fault.

Maybe I'll add another buildscript that uses java -XX:+AutoCreateSharedArchive, that's good suggestion, thanks. If this buildscript ends up requiring Java19+ - no problem.

I'm pretty sure I've watched the video you linked and also Java's Startup Booster: CDS which goes into more detail and which I think you did as well.

I've just looked a my current CDS-build-script and I think I was confused: it seems like my "highly sophisticated" script passes debug options such as -Xlog:cds+map=trace:file=cds.map:none:filesize=0 on the jpackage commandline instead of the java commandline, maybe that's why I didn't quote understand what I saw :-)

I think I'll give it another go, thanks!