Code Monkey home page Code Monkey logo

cl4cds's Introduction

cl4cds (https://github.com/simonis/cl4cds) is a little tool which helps exploring the new Application Class Data Sharing (AppCDS) feature in OpenJDK 10. AppCDS allows sharing of application classes even if they get loaded by a custom class loaders, but unfortunately there’s currently no default tooling available to make this feature accessible to end users. That’s where cl4cds (which is an acronym for "class list for class data sharing") kicks in. It converts a class list obtained from running your application with Xlog:class+load=debug to a format which can be passed to the VM as a parameter of the -XX:SharedClassListFile= option. This article documents the cl4cds tool but at the same time also describes the implementation and the benefits of the ovarall CDS/AppCDS features.

TL;DR

If you’re only interested in the cl4cds utility, you can use it as follows (tested with OpenJDK 10 and Tomcat 9):

$ export JAVA_HOME=JAVA_10_HOME # (1)
$ export CATALINA_OPTS=-Xlog:class+load=debug:file=/tmp/tomcat.classtrace # (2)
$ CATALINA_HOME/bin/catalina.sh start // (3)
$ CATALINA_HOME/bin/catalina.sh stop // (4)
$ JAVA_10_HOME/bin/java io.simonis.cl4cds /tmp/tomcat.classtrace /tmp/tomcat.cls
$ export CATALINA_OPTS="-Xshare:dump -XX:+UseAppCDS -XX:SharedClassListFile=/tmp/tomcat.cls -XX:+UnlockDiagnosticVMOptions -XX:SharedArchiveFile=/tmp/tomcat.jsa" (5)
$ CATALINA_HOME/bin/catalina.sh start (6)
$ export CATALINA_OPTS="-Xshare:on -XX:+UseAppCDS -XX:+UnlockDiagnosticVMOptions -XX:SharedArchiveFile=/tmp/tomcat.jsa" (7)
$ CATALINA_HOME/bin/catalina.sh start (8)
  1. AppCDS only works with OpenJDK 10 and higher

  2. Trace all the classes which get loaded into the file /tmp/tomcat.classtrace

  3. Start Tomcat and run your application

  4. Stop Tomcat

  5. Set the options for creating a shared class archive in /tmp/tomcat.jsa (-XX:SharedArchiveFile is a diagnostic option so we have to enable it first by using -XX:+UnlockDiagnosticVMOptions)

  6. Restart Tomcat to dump the shared class archive

  7. Set the options for using the shared class archive from /tmp/tomcat.jsa

  8. From now on, Tomcat will load available classes (both, system and application ones) from the shared archive if available.

The current cl4cds command line options are as follows:

io.simonis.cl4cds [<class-trace-file> [<class-list-file>]]

  <class-trace-file>: class trace obtained by running -Xlog:class+load=debug
                      if not specified read from <stdin>
  <class-list-file> : class list which can be passed to -XX:SharedClassListFile
                      if not specified written to <stdout>

  The following properties can be used to configure cl4cds:
    -Dio.simonis.cl4cds.debug=true :
       Print additional tracig to <stderr> (defaults to 'false')
    -Dio.simonis.cl4cds.dumpFromClassFile=true :
       Include classes into the output which are loaded from plain classfiles.
       This is currently not supported by OpenJDK 10 which can only dump
       classes from .jar files but may change eventually (defaults to 'false')

If you’re interested in the implementation details of CDS/AppCDS, their current limitations and their performance and memory characteristics please read on the extended version of this article at https://simonis.github.io/cl4cds or visit my talk about Class Data Sharing at FOSDEM 2018.

Colophon

Rendered with AsciiDoctor version 2.0.22

cl4cds's People

Contributors

simonis avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.