Skip to content

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
faster-startupfrom
native-javac
Open

ihid-assistant[bot] wants to merge 1 commit into
faster-startupfrom
native-javac

Conversation

@ihid-assistant

Copy link
Copy Markdown

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

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>
@ihid-assistant
ihid-assistant Bot requested a review from a team as a code owner November 18, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant