Repository navigation
Add dump-warm-image: images of Java programs with their code compiled - #24
Merged
Merged
Conversation
ABCL now boots on JDK 25 and runs its REPL, but two JDK 8 leftovers stopped it right after low-level initialization: - java.util.zip.ZipFile, implemented in Lisp, kept its state in JDK 8's name and jzfile fields. The class takes its fields from JDK 25's ZipFile.class, which has neither, so opening any jar directly failed. Keep the path and open zip in a weak side table instead, as url.lisp already does for JarFile, add the ZipFile(String) constructor, and load ZipEntry before getEntry instantiates it. - UnixFileSystem's getLastModifiedTime0, getLength0 and list0 were only defined under their JDK 8 names. Define the JDK 25 names, returning 0 for a missing file as the JDK does, and have the old names delegate. New aaa/zipfile.java and aaa/filestat.java cover both. docs/ABCL.md and the README now describe the JDK 25 setup and current status. Co-Authored-By: Claude Opus 5.5 <[email protected]>
dump-warm-image runs a Java program on sample inputs (arguments and/or stdin) at build time, then saves an SBCL image with the methods those runs compiled. By default it resets the application's classes first (static fields back to their initial values, <clinit> runs again), so main starts fresh; :reset-classes nil keeps the warmup's state, for programs whose statics their <clinit>s can't rebuild. The pre-save cleanup that lived inside make-javac-image is now the shared %reset-runtime-for-save, which also makes files survive the restart: FileInputStream/FileOutputStream/RandomAccessFile streams reopen at their saved position through an init hook, and ZipFile reopens its jar lazily. make abcl builds ./abcl, a warm ABCL image that reaches its prompt in under a second instead of ~3.5 minutes. ABCLMain reuses an existing interpreter so the booted Lisp in the image is used. The warmup avoids COMPILE: OpenLDK can't yet load ABCL-compiled closures (documented in docs/ABCL.md; it fails cold too). docs/IMAGES.md describes make-image, dump-app-image and dump-warm-image with Kawa, ABCL and javacl as examples. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 20, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on #23, which it includes as its first commit (
815fe06). Merge #23 first, and this PR's diff shrinks to its own commit,64f621d.OpenLDK compiles each Java method on first call, and for a big program that's most of its startup time.
dump-app-image(make kawa) saves a program with its classpath but none of that work.make-javac-imagesaves it, but only for javac. This adds a general version.dump-warm-image(src/cli.lisp)It runs
mainonce per warmup, with arguments and/or stdin, at build time, under the same timeout and error handling as javac's warmups. Then it saves the image with every method those runs compiled.<clinit>runs again on first use, somainstarts fresh.:reset-classes nil. Keeps the state the warmups built, for programs whose<clinit>s can't rebuild their statics.mainhas to reuse that state.Checked with a program that counts its runs in a static field: a fresh JVM prints
runs=1, the default imageruns=1, and the:reset-classes nilimageruns=2.Shared save-time cleanup
The cleanup inside
make-javac-image(threads, locks, classpath handles, jimage buffers, caches) is now%reset-runtime-for-save, shared by both builders. It also makes files survive a restart:FileInputStream,FileOutputStreamandRandomAccessFilestreams open at save time reopen at their saved position, through ansb-ext:*init-hooks*hook. Checked with/dev/urandomand a half-read text file: the image resumes at the next byte.ZipFilereopens its jar lazily.javaclwas rebuilt with the shared cleanup and still compilesHello.javacorrectly.Example:
make abclmake abcldownloads ABCL 1.9.2, compilesABCLMain, and runslib/abcl/build-image.lisp, which warms ABCL up with one REPL session. ABCL's compiled Lisp classes get their statics from its fasl loader, so this example uses:reset-classes nil, andABCLMainnow reuses the interpreter it finds../abcl(quit)defun,defclass,defgeneric,defmethod,loop)The image is 533 MB and builds in about 6 minutes.
Limitation: the warmup doesn't call
compile. OpenLDK can't yet load ABCL-compiled code containing closures, and that fails cold too:(compile 'make-adder)on a closure fails on master. The generated classes refer to each other and only ABCL's in-memory class loader can find them, but the JIT resolves class constants without asking the defining loader (src/classfile.lisp:217) and substitutes a stub. If the warmup preloaded ABCL's compiler, ABCL would also compile forms likedefclassand hit this. It's documented indocs/ABCL.mdas a known issue, along with a second bug found along the way:Field.get(null)on a static field of a custom-loader class returns null.Docs
docs/IMAGES.mdcoversmake-image,dump-app-imageanddump-warm-image, with Kawa, ABCL and javacl as examples, and explains when to use:reset-classes nil. It also flags a catch: in an app image, the first command-line argument is taken as a main class..cache/(already the Makefile'sXDG_CACHE_HOME) and/abclare now gitignored.Testing:
make check-regressioncouldn't run locally (no DejaGnu), so CI's gate is the full check. Locally,zipfile,filestat,waitwake,monitorwakeandjitwakepass on the rebuiltopenldk.🤖 Generated with Claude Code