Repository navigation
Compile solutions with a native javac built with the image (~35% faster on top of #227) - #228
Open
ihid-assistant[bot] wants to merge 1 commit into
Open
ihid-assistant[bot] wants to merge 1 commit into
ihid-assistant[bot] wants to merge 1 commit into
Conversation
Each run spent most of a second loading javac into the JVM and warming it up in the JIT. The Docker build now compiles javac into a native executable with GraalVM Native Image (bin/build-native-javac.sh). The test runner starts it on the solution and tests as soon as it starts, and parses the test files while it runs. If the native javac fails for any reason, the test runner compiles the files again with the JVM's own javac, as before. That keeps compile error messages identical, and handles code that needs a Java release newer than the native javac's. This takes the median run over the track's 169 example solutions from 1.89s to 1.24s, with identical results. Runs with compile errors take about 0.2s longer. The image grows by about 46 MB. Co-authored-by: iHiD <286476+iHiD@users.noreply.github.com> 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 35% faster on top of #227. 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...
This builds on #227, and should be merged after it. It keeps #227's AOT cache, which the tests still use.
What changed
Even with the AOT cache, each run spent most of a second inside javac. javac runs in the same JVM as the tests, so on every run the JIT had to warm javac up from scratch. That work is lost when the run ends.
The Docker build now has a stage that compiles javac into a native executable with GraalVM Native Image (
bin/build-native-javac.sh). A native javac starts in a few milliseconds and runs as machine code from the start. The test runner starts it on the solution and test files at the start of each run, and parses the test files while it compiles. The tests then run on the JVM as before.A native executable can't read the JDK's own classes, so the native javac compiles against the Java 25 API in
lib/ct.sym, using--release 25.If the native javac fails for any reason, the test runner compiles the files again with the JVM's own javac, exactly as it does today. This covers compile errors, so their messages stay identical. It also covers code that needs a Java release newer than 25, and any machine where the native executable can't run. Runs with compile errors take slightly longer, because the native javac runs and fails first.
The AOT cache is now created before the native javac is added to the image. That way the training run compiles inside the JVM, and the cache still holds javac's classes for the runs that fall back to it.
The image grows by about 46 MB.
This has been tested in production, and has reduced the median run from 2.0s to 1.3s.
🤖 Generated with Claude Code