Skip to content

Instantly share code, notes, and snippets.

@thomasdarimont
Last active November 25, 2021 17:12
Show Gist options
  • Save thomasdarimont/be2795e02565ad5ccfb2b4d93635b0ed to your computer and use it in GitHub Desktop.
Save thomasdarimont/be2795e02565ad5ccfb2b4d93635b0ed to your computer and use it in GitHub Desktop.
Making Single-Source Java Programs faster with Application Class data-sharing

Application Class Data Sharing

Application Class Data Sharing (CDS) is an easy way to start a Java application faster. This is mostly used for Desktop and Server applications but it can also be used for JEP 330 Single-Source Java Programms.

If you want to know more about CDS then I recommend this useful article by Gunnar Morling, which covers CDS in more detail.

Results

time java hello.java

> 0,73s user 0,06s system 216% cpu 0,365 total
time java -XX:ArchiveClassesAtExit=hello-app-cds.jsa hello.java

> 1,13s user 0,05s system 201% cpu 0,584 total
time java -XX:SharedArchiveFile=hello-app-cds.jsa -Xshare:on hello.java

> 0,49s user 0,04s system 250% cpu 0,212 total
time java -XX:SharedArchiveFile=hello-app-cds.jsa -Xshare:on -XX:TieredStopAtLevel=1 hello.java

> 0,27s user 0,04s system 171% cpu 0,186 total
class Hello {
public static void main(String[] args) {
System.out.println("Hello JAuld");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment