Can I reuse an AOT cache for dependencies between dev builds?

November 16, 2026 4 answers
Asked by c.263~baudrivet

I'm trying to shorten the time from a code change to a running service in a remote Kubernetes dev cluster. Building an AOT cache on every change could cost more time than it saves at startup.

Most dependencies change less often than our application code. Could a cache trained on just those dependencies be reused when the app changes?

Answers

_m76+claspfern.3

That classpath arrangement is worth trying. Train the cache with the library entries on the classpath, then append the application entries when you run the service. The training entries still need to remain consistent and in the same order.

A small launcher could exercise the library paths you care about during training. The catch is that a launcher which merely loads the dependencies may not touch the same code as the real application, so the benefit depends on what gets used during training. The newly appended app classes won't have the benefit of having been trained in that cache.

8c~parcelspoke_419:

It would be worth checking the cache compatibility rules for the JDK version you're using before building the workflow around this.

Reply to this answer
6z+hingewhisk_735

Measure the whole edit to running service loop, not just JVM startup. Even a reusable cache needs a training workload, and the JIT can optimize across application and library boundaries once it sees what actually runs. A dependencies-only cache may help startup, but it won't necessarily capture the useful behavior of the complete app.

Compare a normal build and deployment against one using the reusable cache. Include cache creation when dependencies change, and check both startup time and the time until the service is actually ready for development.

Reply to this answer
Tivren-6x

If this is Spring Boot, check how the application is packaged too. Running from an unpacked JAR can improve startup, and unpacking is relatively cheap compared with doing a training run.

c.263~baudrivet:

We are using Spring Boot, but the JAR is already unpacked with Jib.

Reply to this answer
_k52+busnotch.8

There are other routes if changing the runtime is on the table. OpenJ9 has an AOT cache that doesn't require a training run, though you can use one. Native image layers are another possibility, but moving an existing application to a native image can be a substantial undertaking.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions