Repository navigation
Conversation
Every run spent more than a second loading and linking the classes of javac, JUnit and AssertJ before it compiled or ran any tests. When the image is built, bin/create-aot-cache.sh now runs the test runner once on a sample exercise in aot-training/ with -XX:AOTCacheOutput. The JVM saves the classes loaded during that run, already loaded and linked, in java-test-runner.aot. bin/run.sh passes that cache to the JVM with -XX:AOTCache, so each run starts from that state. If the JVM can't use the cache, it will print an error and run as before. This takes the median run over the track's 169 example solutions from 3.36s to 1.90s, with identical results. The image grows by about 50 MB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Hello 🙂 I'm working with Claude to try and get our tooling faster.
This PR makes this project around 40% faster. I've run it in production to benchmark things in the real world against the most recent few hundred solutions, so I'm confident that it works robustly. However, I've not written the code. I have tried my hardest to get Claude to write sensible messages and comments that explains stuff, but I'd ask for your patience in the fact I'm sending AI code to you. Everything below here is from your friendly neighbourhood LLM...
What changed
The image now ships a cache of the classes every run needs, already loaded and linked, and the JVM uses it at start-up. The JDK calls this an ahead-of-time (AOT) cache. Before this change, every run started a fresh JVM. Each JVM spent more than a second on start-up work before it touched the student's code. It found, loaded and linked the classes of javac, JUnit and AssertJ, and ran their code in the interpreter. For
bob, that start-up work took about 1.5s of a 3.4s run.When the image is built, the new script
bin/create-aot-cache.shruns the test runner once on a sample exercise inaot-training/, with the JVM flag-XX:AOTCacheOutput. The sample has tests that pass, fail and throw, and it uses parameterized tests, printed output and task tags. This makes the training run load the same classes as a typical student run. The JVM saves those classes injava-test-runner.aot, already loaded and linked, with profiling data about how their methods ran. The cache is built in the final image stage, with the same JDK used at run time.bin/run.shnow passes the cache to the JVM with-XX:AOTCache, so each run starts with those classes already loaded.Long-running tests keep their speed. This change leaves the JIT compilers and the garbage collector alone, and the CPU-heavy exercises (such as
alphametics) took the same time as before when measured.The cache adds about 50 MB to the image (from 432 MB to 485 MB).
If the cache is missing or can't be used, the JVM will print a warning to stderr and run without it, at the old speed. The warning doesn't reach
results.json.This has been tested in production, and has reduced the median run from 3.5s to 2.0s.
🤖 Generated with Claude Code