Repository navigation
Description
Spring Boot already supports the AOT Cache features of modern JVMs, especially when running in JDK 25 and beyond. We should use this for running the language server.
The JDK AOT Cache mechanism is a two-step process:
- training run (run the app, at shutdown, the JVM creates the cache data)
- subsequent runs (the app uses the cached data)
Since the training run has to use the exact same JVM on the exact same architecture as the subsequent runs, we can't create the cache file during build time and ship it with the language server. Instead, we need to do all this on the users machine in the background. But since we control the logic that starts up the language server process when running the Spring Tools, we can do (in the launch logic of the language server):
- start the language server process in training run mode when there is no cache file around yet
- start the language server with the cache settings if the cache file is around
Training mode is enabled via: -XX:AOTCacheOutput=app.aot
Cache usagem mode is enabled via: -XX:AOTCache=app.aot
(assuming that the app.aot is the name of the cache file, we should probably use a more specific one for your case)
Before we enable those options, we need to verify that the language server runs on a JDK >= 25. If not, we do not enable those options. Once we move the minimum requirement to run the language server up to JDK 25, we can always run those options, of course. But at the moment, the language server can still run on a JDK 21.
Updating the cache: Since the language server install directory is a fresh one every time an update of the language server is installed, we don't need to worry about outdated cache files - as long as the cache file is located next to the language server JAR. The only case we need to track here is whether the cache file was created using the exact same JVM - since that can be changed anytime.
Activity
martinlippert commentedon Feb 6, 2026
Btw, early measurements show that the startup time of the language server is cut into less than half using this cache mechanism... 🥳
martinlippert commentedon Feb 6, 2026
Early experiments show messages regarding JDT core classes being skipped due to signed JAR files, we need to investigate this further, but that should not prevent us from enabling this. The nice startup performance improvements can be achieved nevertheless. But further improvements in this space might need to solve this.
martinlippert commentedon Mar 3, 2026
Moved the additional improvements to a separate issue: #1824
BoykoAlex commentedon Mar 3, 2026
I have been only having aot warnings about spring-core.7.0.2.jar... I had to turn that logging off... Redirecting to stederr din't help for some reason... AI blamed logback and spring-boot logging redirects for that.
BoykoAlex commentedon Mar 4, 2026
@martinlippert Where do you think the preferences for enabling CDS be? Currently it is on the Spring -> Logs page...
martinlippert commentedon Mar 4, 2026
I think having the preference directly in the main category should be fine. Looks like we have some of those preferences that don't have another home there... 😀
martinlippert commentedon Mar 4, 2026
I've seen now that you renamed the title of the logs preference page to be more general around the language server, which seems to be fine with me as well. Let's go with that and ignore my previous comment.
martinlippert commentedon Mar 5, 2026
This doesn't seem to work yet on the VSCode side. The aot cache file is produced after the first run, but it isn't taken into account for subsequent runs. Instead, the language server VM is started with
-XX:AOTCacheOutput=....again, which produces a new aot cache file, but doesn't take the existing into account at startup.martinlippert commentedon Mar 5, 2026
In contrast, the latest Eclipse-based snapshot builds work perfectly well (and I see the impressing startup speed improvements) 🚀
martinlippert commentedon Mar 9, 2026
Ships as part of the
5.1.0release as an early-access experimental feature. Further improvements will be part of future releases.The short summary of what is implemented for
5.1.0is: