[wildfly-dev] Reducing Startup Time and Footprint with AppCDS
Philippe Marschall
kustos at gmx.net
Sun Feb 18 06:12:26 EST 2018
Hello
There has been a lot of talk on this list about how startup time and
footprint of WildFly can be reduced even further. I have experimented
with AppCDS and the first results are encouraging.
As you may be aware Application Class-Data Sharing, or AppCDS for short,
is available in OpenJDK 10 [1].
My work is based on the excellent talk of Volker Simonis on the subject
at FOSEM [2] and his cl4cds [3] tool. I recommend viewing his
presentation first, it will provide a lot of background.
To get started you first need download an OpenJDK 10 early access build
from [4]. It is important to not download an OracleJDK build as AppCDS
is missing there for some reason.
Then you need to dump the list of loaded classes
export
PREPEND_JAVA_OPTS="-Xlog:class+load=debug:file=/tmp/wildfly.classtrace"
./bin/standalone.sh
Followed by converting that to a class list suitable for AppCDS, this is
where the cl4cds tool comes in
$JAVA_HOME/bin/java -jar ~/git/cl4cds/target/cl4cds-1.0.0-SNAPSHOT.jar
/tmp/wildfly.classtrace /tmp/wildfly.cls
Then you can create the shared archive
export PREPEND_JAVA_OPTS="-Xshare:dump -XX:+UseAppCDS
-XX:SharedClassListFile=/tmp/wildfly.cls -XX:+UnlockDiagnosticVMOptions
-XX:SharedArchiveFile=/tmp/wildfly.jsa"
./bin/standalone.sh
and then finally you can start WildFly with the shared archive
export PREPEND_JAVA_OPTS="-Xshare:on -XX:+UseAppCDS
-XX:+UnlockDiagnosticVMOptions -XX:SharedArchiveFile=/tmp/wildfly.jsa"
./bin/standalone.sh
I checked the startup time reported by an "empty" WildFly 11. I realize
this is not the most scientific way. The startup time went down from
about 2000ms to about 1500ms or by about 25%. I did not have a look at
the memory savings when running multiple WildFly versions is parallel.
One thing I noted is that the Xerces classes should probably be
recompiled with bytecode major version 49 (Java 1.5) or later, otherwise
they can not be processed by AppCDS.
Unfortunately AppCDS is quite hard to use, I don't know if the WildFly
project can somehow help to make this easier. One option would be to
ship a class list file but I don't know how portable that is. Also as
WildFly services are lazy it only a fraction of the required classes may
be in there.
[1] http://openjdk.java.net/jeps/310
[2] https://fosdem.org/2018/schedule/event/class_data_sharing/
[3] https://simonis.github.io/cl4cds/
[4] http://jdk.java.net/10/
Cheers
Philippe
More information about the wildfly-dev
mailing list