orthonym.jvm_cds#

Note

Internal API. Names and behaviour may change between releases.

A class-data archive (AppCDS) for the in-process JVM: a new process starts its JVM about 0.2 s sooner.

The JVM of a new process spends most of its first second loading and checking the classes of OPSIN and centres. A dynamic class-data archive (JDK 19 and later) holds them ready to map. Measured on JDK 21: start, OPSIN’s set-up and the first parse 0.75 s without the archive, 0.56 s with it (four runs each, no overlap); a one-shot orthonym CCO takes about 1.9 s.

Where it lives. <jar directory>/cds/<key>.jsa, in the directory of the jars and under the same checks (jars.check_jar_dir): the JVM maps the archive as it loads a jar, so no other user may be able to put one there. The key is the JVM library, the JDK version, the JPype version and each jar of the class path (path, size, time), so a new JDK or jar gets an archive of its own.

Who makes it. Only a process that started the JVM itself and asked for it (build_if_missing(), called at the end of a command-line run): a child process starts the JVM with -XX:ArchiveClassesAtExit on a file of its own, names one structure and exits; the parent moves the finished file into place (os.replace, atomic). A reader therefore never sees a half-written archive, and the workers of --jobs (whose parent starts no JVM) only read. The child runs in the archive’s directory, so that a module in the user’s working directory is never imported by it. A build that leaves no archive (a JDK without a base archive, a JVM that ignores the option, a crash) leaves <key>.failed instead, and no later run tries that key again; the four newest archives are kept.

What a JVM does with a missing, foreign or damaged archive: it starts without it. It would say so on STANDARD OUTPUT through its unified logging ([warning][cds] shared class paths mismatch), which is the class of fault that shifted the rows of a batch parse (jvm_flags); the archive is therefore always passed with -Xlog:cds*=off and -Xlog:class+path*=off. ORTHONYM_JVM_CDS=off turns all of it off.

orthonym.jvm_cds.MIN_JDK = 19#

The first JDK whose dynamic archives this module uses (-XX:+AutoCreateSharedArchive came with 19).

orthonym.jvm_cds.LOG_FLAGS = ('-Xlog:cds*=off', '-Xlog:class+path*=off')#

The JVM’s own messages about the archive, which go to standard output, switched off.

orthonym.jvm_cds.archive_path(classpath)#

The archive for a JVM with classpath (it may not exist yet), or None when none is used here: turned off, a JDK before:data:MIN_JDK, or no jar directory that passes the checks.

orthonym.jvm_cds.build_if_missing(timeout=60.0)#

Make the archive of this process’s JVM when it has none, and return its path (None when there is nothing to make). Only after this process started the JVM itself: a process that named nothing makes nothing.

orthonym.jvm_cds.jdk_major(jvm_library)#

The major version of the JDK that holds jvm_library, or None when it cannot be read.

orthonym.jvm_cds.start_options(classpath)#

The options that make a JVM with classpath use its archive ( when there is none to use), or, in the child of:func:build_if_missing, write it.