-
Notifications
You must be signed in to change notification settings - Fork 223
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.