From 5ea1ccc412db59d50ec3d60b99dee08d44d4c90d Mon Sep 17 00:00:00 2001 From: Raman Gupta Date: Tue, 17 Nov 2026 16:53:55 -0500 Subject: [PATCH 1/4] build: add an aotCache task for a JVM AOT cache training run The bootable.aot-cache plugin, in a new build-logic included build, adds an aotCache task to an application: it runs the installed distribution once, by its start script, on the project's toolchain, with -XX:AOTCacheOutput, waits for Bootable's "=> Running" line, sends the requests given to it, and stops it with SIGTERM, so the JVM writes the cache as it exits. - AotCacheTraining runs any command, so a container's training can use it too. - The task reruns when the installed jars' modification times change, as the JVM checks them against the cache. - The vanilla server-ktor-db example trains with a few requests, so the cache covers the request path too. --- build-logic/build.gradle.kts | 14 ++ build-logic/settings.gradle.kts | 9 + build-logic/src/main/kotlin/AotCache.kt | 225 ++++++++++++++++++ .../server-ktor-db/vanilla/build.gradle.kts | 17 ++ settings.gradle.kts | 5 + 5 files changed, 270 insertions(+) create mode 100644 build-logic/build.gradle.kts create mode 100644 build-logic/settings.gradle.kts create mode 100644 build-logic/src/main/kotlin/AotCache.kt diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts new file mode 100644 index 0000000..7382239 --- /dev/null +++ b/build-logic/build.gradle.kts @@ -0,0 +1,14 @@ +// Build logic for the examples: plugins they apply, kept free of anything specific to this repository, so a +// downstream application can copy a plugin's file into its own buildSrc or build-logic. +plugins { + `kotlin-dsl` +} + +gradlePlugin { + plugins { + register("aotCache") { + id = "bootable.aot-cache" + implementationClass = "AotCachePlugin" + } + } +} diff --git a/build-logic/settings.gradle.kts b/build-logic/settings.gradle.kts new file mode 100644 index 0000000..362d954 --- /dev/null +++ b/build-logic/settings.gradle.kts @@ -0,0 +1,9 @@ +rootProject.name = "build-logic" + +dependencyResolutionManagement { + @Suppress("UnstableApiUsage") + repositories { + mavenCentral() + gradlePluginPortal() + } +} diff --git a/build-logic/src/main/kotlin/AotCache.kt b/build-logic/src/main/kotlin/AotCache.kt new file mode 100644 index 0000000..6ab852a --- /dev/null +++ b/build-logic/src/main/kotlin/AotCache.kt @@ -0,0 +1,225 @@ +import java.io.File +import java.io.Serializable +import java.net.URI +import java.net.http.HttpClient +import java.net.http.HttpRequest +import java.net.http.HttpResponse +import java.time.Duration +import java.util.concurrent.TimeUnit +import org.gradle.api.DefaultTask +import org.gradle.api.GradleException +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.file.ConfigurableFileCollection +import org.gradle.api.file.DirectoryProperty +import org.gradle.api.file.RegularFileProperty +import org.gradle.api.plugins.JavaApplication +import org.gradle.api.plugins.JavaPluginExtension +import org.gradle.api.provider.ListProperty +import org.gradle.api.provider.MapProperty +import org.gradle.api.provider.Property +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputFiles +import org.gradle.api.tasks.Internal +import org.gradle.api.tasks.OutputFile +import org.gradle.api.tasks.PathSensitive +import org.gradle.api.tasks.PathSensitivity +import org.gradle.api.tasks.Sync +import org.gradle.api.tasks.TaskAction +import org.gradle.jvm.toolchain.JavaToolchainService +import org.gradle.work.DisableCachingByDefault + +/** + * An HTTP request sent to the application during an [AotCacheTraining] run, once it is ready, so the training also + * loads and links the classes of the request path, not just those of the start. + */ +data class TrainingRequest(val method: String, val url: String, val body: String? = null) : Serializable + +/** + * A JVM AOT cache training run (JEP 483 and 514, JDK 24+). + * + * It runs [command], which starts the application with `-XX:AOTCacheOutput=`, waits for a line of its + * output matching [readyPattern], sends [requests] [rounds] times, then stops it with SIGTERM: the JVM writes the AOT + * cache as it exits, and the task checks that [cacheFile] is there. + * + * The cache is only used by a JVM of the same JDK build, with the same class path, of jars of the same sizes and + * modification times, as the training run's; otherwise the JVM warns, and runs without it. So the command should run + * the application as it ships: the installed distribution, or the container image. + * + * Unix only: the JVM writes the cache when it exits normally, and Windows has no SIGTERM to ask it to. + */ +@DisableCachingByDefault(because = "the cache is only valid for the exact files, timestamps included, it was trained with") +abstract class AotCacheTraining : DefaultTask() { + /** The command that starts the application, with `-XX:AOTCacheOutput` set to [cacheFile] in some way. */ + @get:Input + abstract val command: ListProperty + + /** Environment variables for [command], added to the build's own. */ + @get:Input + abstract val environment: MapProperty + + @get:Internal + abstract val workingDir: DirectoryProperty + + /** The files of the application that [command] runs, so the training runs again when they change. */ + @get:InputFiles + @get:PathSensitive(PathSensitivity.RELATIVE) + abstract val trainedFiles: ConfigurableFileCollection + + /** A regular expression matching the line the application logs once it is ready: Bootable's `=> Running`. */ + @get:Input + abstract val readyPattern: Property + + @get:Input + abstract val requests: ListProperty + + @get:Input + abstract val rounds: Property + + @get:Internal + abstract val startTimeout: Property + + /** How long the application may take to exit after SIGTERM, which includes the JVM writing the cache. */ + @get:Internal + abstract val stopTimeout: Property + + @get:OutputFile + abstract val cacheFile: RegularFileProperty + + /** The application's output, during the training; by default, next to [cacheFile]. */ + @get:Internal + abstract val logFile: RegularFileProperty + + init { + readyPattern.convention("""=> Running \(""") + rounds.convention(1) + startTimeout.convention(Duration.ofMinutes(2)) + stopTimeout.convention(Duration.ofMinutes(2)) + workingDir.convention(project.layout.buildDirectory.dir("aot/work")) + logFile.convention(project.layout.file(cacheFile.locationOnly.map { it.asFile.resolveSibling("${it.asFile.name}.log") })) + } + + /** Sends a request to the application, during the training, once it is ready. */ + fun request(method: String, url: String, body: String? = null) { + requests.add(TrainingRequest(method, url, body)) + } + + @TaskAction + fun train() { + if (System.getProperty("os.name").startsWith("Windows")) { + throw GradleException("AOT cache training stops the application with SIGTERM, which Windows doesn't have") + } + val cache = cacheFile.get().asFile + cache.delete() + cache.parentFile.mkdirs() + val dir = workingDir.get().asFile.apply { mkdirs() } + + val log = logFile.get().asFile.apply { parentFile.mkdirs() } + logger.info("AOT cache training: {} with {}, output in {}", command.get(), environment.get(), log) + // The output goes to a file, not a pipe: the JVM writes the cache as it exits, in a child JVM that shares its + // output, and with a pipe read by this task, the shutdown's output was lost, and the child never wrote the cache. + val process = ProcessBuilder(command.get()) + .directory(dir) + .redirectErrorStream(true) + .redirectOutput(log) + .apply { environment().putAll(this@AotCacheTraining.environment.get()) } + .start() + + fun fail(message: String): Nothing { + process.destroyForcibly() + val tail = log.readLines().takeLast(40).joinToString("\n") + throw GradleException("$message; the application's output is in $log, and ends with:\n$tail") + } + + try { + val pattern = Regex(readyPattern.get()) + val deadline = System.nanoTime() + startTimeout.get().toNanos() + log.bufferedReader().use { output -> + while (true) { + val line = output.readLine() + if (line == null) { + if (!process.isAlive) fail("The application exited (${process.exitValue()}) before it was ready") + if (System.nanoTime() > deadline) fail("The application wasn't ready within ${startTimeout.get()}") + Thread.sleep(50) + } else if (pattern.containsMatchIn(line)) { + break + } + } + } + logger.lifecycle("The application is ready; training with ${requests.get().size} request(s), ${rounds.get()} time(s)") + sendRequests(::fail) + + // SIGTERM: the JVM runs its shutdown hooks, so the application stops as it would in production, then writes + // the cache + process.destroy() + if (!process.waitFor(stopTimeout.get().toMillis(), TimeUnit.MILLISECONDS)) { + fail("The application didn't exit within ${stopTimeout.get()} of SIGTERM") + } + } finally { + if (process.isAlive) process.destroyForcibly() + } + + if (!cache.isFile) fail("The application exited (${process.exitValue()}), but wrote no AOT cache at $cache") + logger.lifecycle("AOT cache: $cache (${cache.length() / (1024 * 1024)} MB)") + } + + private fun sendRequests(fail: (String) -> Nothing) { + if (requests.get().isEmpty()) return + val client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(10)).build() + repeat(rounds.get()) { + for (request in requests.get()) { + val publisher = request.body?.let { HttpRequest.BodyPublishers.ofString(it) } ?: HttpRequest.BodyPublishers.noBody() + val response = try { + client.send( + HttpRequest.newBuilder(URI(request.url)).method(request.method, publisher).timeout(Duration.ofSeconds(30)).build(), + HttpResponse.BodyHandlers.discarding(), + ) + } catch (e: Exception) { + fail("Training request ${request.method} ${request.url} failed: $e") + } + if (response.statusCode() >= 400) { + fail("Training request ${request.method} ${request.url} returned ${response.statusCode()}") + } + } + } + } +} + +/** + * Adds an `aotCache` task to an application (the `application` plugin): an [AotCacheTraining] run of the installed + * distribution (`installDist`), by its start script, on the project's Java toolchain, so the cache matches the + * application as it ships. + * + * Run the installed application with the cache with `JAVA_OPTS=-XX:AOTCache=build/aot/.aot`. The cache also + * matches a copy of the installed directory that keeps the files' modification times, such as `cp -a`, `rsync -a` or + * a tar archive of it, on the same JDK build. + */ +class AotCachePlugin : Plugin { + override fun apply(project: Project) = with(project) { + pluginManager.withPlugin("application") { + val application = extensions.getByType(JavaApplication::class.java) + val toolchains = extensions.getByType(JavaToolchainService::class.java) + val launcher = toolchains.launcherFor(extensions.getByType(JavaPluginExtension::class.java).toolchain) + val installDist = tasks.named("installDist", Sync::class.java) + val installDir = installDist.map { it.destinationDir } + val applicationName = provider { application.applicationName } + + tasks.register("aotCache", AotCacheTraining::class.java) { + group = "application" + description = "Runs the installed application once, to write its JVM AOT cache" + trainedFiles.from(installDist) + // the JVM checks the jars' modification times against the cache, so a copy of the same jars with new times, + // such as a rerun of installDist, needs a new training run + inputs.property("installedFileTimestamps", installDir.map { dir -> + dir.walkTopDown().filter { it.isFile }.map { "${it.relativeTo(dir)}:${it.lastModified()}" }.sorted().toList() + }) + cacheFile.convention(layout.buildDirectory.file(applicationName.map { "aot/$it.aot" })) + command.add(installDir.zip(applicationName) { dir, name -> File(dir, "bin/$name").path }) + environment.put("JAVA_HOME", launcher.map { it.metadata.installationPath.asFile.path }) + // locationOnly: the path, without the dependency on this task that its output carries + environment.put("JAVA_OPTS", cacheFile.locationOnly.map { "-XX:AOTCacheOutput=${it.asFile.path}" }) + } + Unit + } + } +} diff --git a/examples/server-ktor-db/vanilla/build.gradle.kts b/examples/server-ktor-db/vanilla/build.gradle.kts index 64f01ff..b8874da 100644 --- a/examples/server-ktor-db/vanilla/build.gradle.kts +++ b/examples/server-ktor-db/vanilla/build.gradle.kts @@ -1,6 +1,8 @@ plugins { kotlin("jvm") application + // aotCache: a training run of the installed app, which writes its JVM AOT cache + id("bootable.aot-cache") } kotlin { @@ -30,3 +32,18 @@ dependencies { application { mainClass.set("AppKt") } + +// The training run serves a few requests too, so the cache covers the request path, not just the start. It listens +// on a port of its own, and keeps its database under build/aot. +val trainingHostPort = "127.0.0.1:18001" + +tasks.aotCache { + environment.put("SERVER_HOSTPORT", trainingHostPort) + request("PUT", "http://$trainingHostPort/entries/trained", "by the AOT training run") + request("GET", "http://$trainingHostPort/entries/trained") + request("GET", "http://$trainingHostPort/entries") + request("GET", "http://$trainingHostPort/") + request("GET", "http://$trainingHostPort/metrics") + request("DELETE", "http://$trainingHostPort/entries/trained") + rounds = 20 +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 7379476..c4c7785 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,5 +1,10 @@ rootProject.name = "bootable" +pluginManagement { + // plugins for the examples, such as bootable.aot-cache + includeBuild("build-logic") +} + dependencyResolutionManagement { @Suppress("UnstableApiUsage") repositories { From ab7d4f214f28e9040f47f1908744c01692edbecc Mon Sep 17 00:00:00 2001 From: Raman Gupta Date: Tue, 17 Nov 2026 16:53:58 -0500 Subject: [PATCH 2/4] examples: build server-ktor-db into a Jib image with its AOT cache The cache is trained in a container of the image itself, so it matches the image's JDK build and class path: jibBuildTar builds the image without a cache, the container runtime loads it, aotCache runs it with -XX:AOTCacheOutput and the cache's directory mounted, and jibDockerBuild (or jib) builds the final image with the cache as one more layer and -XX:AOTCache in its JVM flags. - Jib's images are reproducible, so the final image's jars match the training's, modification times included. - containerizingMode is packaged: the JVM won't use a cache with a non-empty directory on the class path. - -PcontainerCli=podman runs it with Podman. --- build.gradle.kts | 1 + examples/server-ktor-db/jib/build.gradle.kts | 137 +++++++++++++++++++ gradle/libs.versions.toml | 2 + settings.gradle.kts | 1 + 4 files changed, 141 insertions(+) create mode 100644 examples/server-ktor-db/jib/build.gradle.kts diff --git a/build.gradle.kts b/build.gradle.kts index 7b1b22a..9445eb1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,6 +17,7 @@ plugins { alias(libs.plugins.kotlin.jvm) alias(libs.plugins.dokka) alias(libs.plugins.dokka.javadoc) + alias(libs.plugins.jib) apply false alias(libs.plugins.kilua) apply false alias(libs.plugins.metro) apply false alias(libs.plugins.kotlin.compose) apply false diff --git a/examples/server-ktor-db/jib/build.gradle.kts b/examples/server-ktor-db/jib/build.gradle.kts new file mode 100644 index 0000000..95d353a --- /dev/null +++ b/examples/server-ktor-db/jib/build.gradle.kts @@ -0,0 +1,137 @@ +plugins { + kotlin("jvm") + alias(libs.plugins.jib) + // for AotCacheTraining: this project has no application plugin, so the plugin adds no aotCache task of its own + id("bootable.aot-cache") +} + +kotlin { + jvmToolchain(25) +} + +// The vanilla app, as a container image with its JVM AOT cache in it. +// +// The cache is only used by the same JDK build, with the same class path, of jars of the same sizes and modification +// times, as the training run's. So the training runs in a container of the image itself: jibBuildTar builds it, +// without a cache, the container runtime loads it, and aotCache runs it once, with the cache's directory mounted +// from the build. Jib's images are reproducible, with every file's modification time fixed, so the final image, which +// jibDockerBuild (or jib) builds with the cache as one more layer, has the same jars as the one the cache was trained +// in, on the same base image. +dependencies { + implementation(project(":examples:server-ktor-db:vanilla")) +} + +// the container runtime's command: docker, or podman, with -PcontainerCli=podman +val containerCli = providers.gradleProperty("containerCli").orElse("docker") +val imageName = "bootable-examples/server-ktor-db-jib" +val mainClassName = "AppKt" +val cacheDir = "/app/aot" +val cacheName = "server-ktor-db.aot" +// the image's JVM flags, but for the cache's +val appJvmFlags = listOf() +// the final image's extra layer: empty for the training image, and the cache for the final one +val aotLayer = layout.buildDirectory.dir("aot-layer") +// where the training container writes the cache, mounted at cacheDir +val trainedCacheDir = layout.buildDirectory.dir("aot/cache") + +jib { + from { + // a JRE is enough for both the training and the application; the training's JDK build is the image's own + image = "eclipse-temurin:25-jre" + } + to { + image = imageName + } + container { + mainClass = mainClassName + jvmFlags = appJvmFlags + "-XX:AOTCache=$cacheDir/$cacheName" + // the application's own classes as a jar, rather than Jib's default /app/classes and /app/resources: the JVM + // can't use an AOT cache with a class path that has a directory in it, other than an empty one + containerizingMode = "packaged" + ports = listOf("8001") + // the config's database path is relative to the working directory, /, which the server can't write + environment = mapOf("DB_JDBC_PATH" to "/tmp/entries.db") + } + extraDirectories { + // build/aot-layer/app/aot/server-ktor-db.aot, as /app/aot/server-ktor-db.aot, in the final image + paths { + path { + setFrom(aotLayer.get().asFile.toPath()) + into = "/" + } + } + } + dockerClient { + // Jib takes a path, not a command, for any executable but its default, docker + executable = containerCli.map { cli -> + if (cli == "docker" || File(cli).isAbsolute) cli + else System.getenv("PATH").split(File.pathSeparator).map { File(it, cli) }.firstOrNull { it.canExecute() }?.path ?: cli + }.get() + } +} + +// the image without a fresh cache, in a tar, for the training run +val trainingImageTar = layout.buildDirectory.file("jib-image.tar") + +val loadTrainingImage = tasks.register("loadTrainingImage") { + description = "Loads the image that jibBuildTar built into the container runtime, for the AOT cache training" + dependsOn(tasks.jibBuildTar) + inputs.file(trainingImageTar) + commandLine(containerCli.get(), "load", "--input", trainingImageTar.get().asFile.path) +} + +// the training container's port for the server, on the host +val trainingPort = 18002 + +val aotCache = tasks.register("aotCache") { + group = "application" + description = "Runs the image once, in a container, to write its JVM AOT cache" + dependsOn(loadTrainingImage) + // the image's content: Jib's tar is reproducible, so this reruns only when the image changes + trainedFiles.from(trainingImageTar) + cacheFile = trainedCacheDir.map { it.file(cacheName) } + logFile = layout.buildDirectory.file("aot/$cacheName.log") + // The image's own entrypoint, but for -XX:AOTCacheOutput in place of -XX:AOTCache: the JVM takes only one of + // them. SIGTERM to the container runtime's client goes on to the JVM, which writes the cache into the mounted + // directory as it exits. + command.addAll(containerCli.map { cli -> + listOf( + cli, "run", "--rm", + "--publish", "127.0.0.1:$trainingPort:8001", + // Z: relabelled for SELinux, where it's enabled + "--volume", "${trainedCacheDir.get().asFile}:$cacheDir:Z", + "--entrypoint", "java", + imageName, + ) + appJvmFlags + listOf( + "-XX:AOTCacheOutput=$cacheDir/$cacheName", + "-cp", "@/app/jib-classpath-file", + mainClassName, + ) + }) + val url = "http://127.0.0.1:$trainingPort" + request("PUT", "$url/entries/trained", "by the AOT training run") + request("GET", "$url/entries/trained") + request("GET", "$url/entries") + request("GET", "$url/") + request("GET", "$url/metrics") + request("DELETE", "$url/entries/trained") + rounds = 20 +} + +// the training image has no cache, so its tar, and the training, only change when the application does +tasks.jibBuildTar { + // Jib needs the directory, if empty + doFirst { aotLayer.get().asFile.run { deleteRecursively(); mkdirs() } } +} + +val aotCacheLayer = tasks.register("aotCacheLayer") { + description = "Puts the AOT cache in the final image's extra layer" + from(aotCache) + into(aotLayer.map { it.dir(cacheDir.removePrefix("/")) }) + // after jibBuildTar, which empties it + mustRunAfter(tasks.jibBuildTar) +} + +// the images with the cache: jibDockerBuild into the container runtime, jib to a registry +tasks.jibDockerBuild { dependsOn(aotCacheLayer) } +tasks.jib { dependsOn(aotCacheLayer) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e06d5d4..a3a63c6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,6 +9,7 @@ hikari = "7.1.0" hoplite = "3.0.5" # 4.0.0 is out, but npm tags it next rather than latest, and Ktor's HTMX attributes follow htmx 2 htmx = "2.0.11" +jib = "3.5.4" kilua = "0.0.36" kotlin = "2.4.21" kotlinx-coroutines = "1.11.0" @@ -37,6 +38,7 @@ vanniktech-publish = "0.37.0" dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } dokka-javadoc = { id = "org.jetbrains.dokka-javadoc", version.ref = "dokka" } graalvm-native = { id = "org.graalvm.buildtools.native", version.ref = "graalvm-buildtools" } +jib = { id = "com.google.cloud.tools.jib", version.ref = "jib" } kilua = { id = "dev.kilua", version.ref = "kilua" } kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } diff --git a/settings.gradle.kts b/settings.gradle.kts index c4c7785..c67dcfd 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -70,6 +70,7 @@ include(":examples:kilua:server") include(":examples:kilua:shared") include(":examples:server-ktor") include(":examples:server-ktor-db:common") +include(":examples:server-ktor-db:jib") include(":examples:server-ktor-db:kodein") include(":examples:server-ktor-db:metro") include(":examples:server-ktor-db:vanilla") From f14b0cfb123422182e90f3d388915a7470c50477 Mon Sep 17 00:00:00 2001 From: Raman Gupta Date: Tue, 17 Nov 2026 16:53:59 -0500 Subject: [PATCH 3/4] docs: document the JVM AOT cache, its gain, and the Jib image How to produce the cache and run with it, what has to match for the JVM to use it, the measured start times with and without it, and how the Jib example trains it in its own image. --- README.adoc | 112 ++++++++++++++++++++++++++++ examples/server-ktor-db/README.adoc | 22 ++++++ 2 files changed, 134 insertions(+) diff --git a/README.adoc b/README.adoc index 057a2c2..555e87e 100644 --- a/README.adoc +++ b/README.adoc @@ -368,6 +368,118 @@ To use a DI framework, depend on the `-kodein` or `-metro` artifact of each modu * *Kodein* (runtime): import the provided `bootableModule` / `hopliteConfigModule` / `environmentModule`, contribute your services with `bindAppService { … }`, and pass the resolved sets to `boot`. * *Metro* (compile-time): declare a `@DependencyGraph` that extends `BootableGraph`, contribute your services with `@ContributesIntoSet`, and `boot { createGraph().bootable }`. +== Faster Start: the JVM AOT Cache + +On JDK 24 and later, an AOT cache (https://openjdk.org/jeps/483[JEP 483], with the one-step training of https://openjdk.org/jeps/514[JEP 514] in JDK 25) holds the classes an application loaded and linked during a training run, so the next start reads them from the cache instead of loading, verifying and linking them again. +A Bootable application's start loads thousands of classes, from Log4j, Hoplite, the database and telemetry libraries, and Ktor, so it gains a lot from one. +See Spring's https://docs.spring.io/spring-framework/reference/integration/aot-cache.html[guide to the AOT cache] for more on how it works. + +=== Producing the cache + +The training run starts the application with `-XX:AOTCacheOutput=`, and the JVM writes the cache when the application exits. +The `bootable.aot-cache` plugin in link:./build-logic[build-logic] adds an `aotCache` task to an application, which does that with the installed distribution (`installDist`), by its start script, on the project's Java toolchain: + +* it starts the application, and waits for Bootable's `+=> Running+` line, which it logs once every service has started; +* it sends the application the requests given to it, if any, so the cache also covers the request path, not just the start; +* it stops the application with SIGTERM, so it shuts down as it would in production, and the JVM writes the cache as it exits. + +[source,kotlin] +---- +plugins { + application + id("bootable.aot-cache") +} + +tasks.aotCache { + environment.put("SERVER_HOSTPORT", "127.0.0.1:18001") + request("PUT", "http://127.0.0.1:18001/entries/trained", "by the AOT training run") + request("GET", "http://127.0.0.1:18001/entries/trained") + rounds = 20 +} +---- + +The plugin is one file, `AotCache.kt`, with no dependencies but Gradle's own, so an application outside this repository can copy it into its own `buildSrc` or build logic. +The task type, `AotCacheTraining`, runs any command that starts the application with `-XX:AOTCacheOutput`, such as a container, as the Jib example below does. +The training needs a JVM that writes the cache as it exits, on SIGTERM, so it runs on Linux and macOS, not Windows. + +[source,shell] +---- +./gradlew :examples:server-ktor-db:vanilla:aotCache +---- + +writes `examples/server-ktor-db/vanilla/build/aot/vanilla.aot`, and the application's output during the training next to it, in `vanilla.aot.log`. +The cache is about 66 MB for that example, or 60 MB for a training run that only starts it. + +=== Running with the cache + +Run the application with `-XX:AOTCache=`, on the same JDK, from the same installed directory: + +[source,shell] +---- +cd examples/server-ktor-db/vanilla +JAVA_OPTS=-XX:AOTCache=build/aot/vanilla.aot build/install/vanilla/bin/vanilla +---- + +The JVM only uses the cache with the JDK build that wrote it, and the same class path, of the same jars, which it checks by their sizes and modification times. +On any difference, it warns, such as `The AOT cache was created by a different version or build of HotSpot`, or `This file is not the one used while building the AOT cache`, and runs without the cache. +So train with the application as it ships, and ship them together: + +* the installed directory can move, but a copy of it has to keep the files' modification times, as `cp -a`, `rsync -a` or a tar archive of it do; a rerun of `installDist` writes new ones, so `aotCache` runs again after it; +* in a container image, train in a container of the image itself, as the Jib example below does. + +`-XX:AOTMode=on` makes the JVM fail to start rather than run without the cache, which shows a mismatch at once. +`-Xlog:aot` logs whether the JVM opened the cache, and `-Xlog:class+load` logs each class that came from it with `source: shared objects file`. + +=== The gain + +On the vanilla link:./examples/server-ktor-db[examples/server-ktor-db] app, on JDK 25, the median of 7 starts: + +[cols="2,1,1"] +|=== +| | Without the cache | With the cache + +| From launch to `+=> Running+` +| 721 ms +| 307 ms + +| From `boot` to `+=> Running+` +| 690 ms +| 229 ms + +| From `boot` to the services starting +| 485 ms +| 160 ms + +| The first `PUT /entries/{name}` +| 44 ms +| 12 ms +|=== + +The cache held 8,217 of the 8,368 classes the application loaded through its start and those first requests. +A cache from a training run that only starts the application starts it as fast, but leaves the first request at 47 ms: the training's requests are what cover the request path. + +=== In a container image, with Jib + +link:./examples/server-ktor-db/jib[examples/server-ktor-db/jib] builds the vanilla app into a container image, with https://github.com/GoogleContainerTools/jib[Jib], with its AOT cache in it: + +. `jibBuildTar` builds the image without a cache, and the container runtime loads it; +. `aotCache` runs that image once, in a container, with `-XX:AOTCacheOutput` in place of the image's `-XX:AOTCache`, and the cache's directory mounted from the build, so the training runs on the image's own JDK, with its class path, `-cp @/app/jib-classpath-file`; +. `jibDockerBuild`, or `jib` to push to a registry, builds the final image, with the cache as one more layer, at `/app/aot/server-ktor-db.aot`, and `-XX:AOTCache` in its JVM flags. + +Jib's images are reproducible, with every file's modification time fixed, so the final image's jars are the same, to the JVM, as those the cache was trained with. +Two settings make the cache usable at all: `containerizingMode = "packaged"`, which puts the application's own classes in a jar, as the JVM won't use a cache with a non-empty directory on the class path, as Jib's default `/app/classes` is; and the training's entrypoint, the image's own but for the cache's flag, as the JVM takes only one of `-XX:AOTCache` and `-XX:AOTCacheOutput`. + +[source,shell] +---- +./gradlew :examples:server-ktor-db:jib:jibDockerBuild -PcontainerCli=podman +podman run --rm -p 8001:8001 bootable-examples/server-ktor-db-jib +---- + +`containerCli` is the container runtime's command, for loading and running the training image and for `jibDockerBuild`: `docker` by default, or `podman`. +The cache adds a 64 MB layer to the image, which used 8,259 of the 8,403 classes the application loaded in it, and started from launch to `+=> Running+` in a median of 390 ms with the cache, and 819 ms without it, over 7 starts, each in a new container. + +The JVM's choice of garbage collector, and so part of what the cache holds, depends on the container's memory and CPUs: train with the same limits the application runs with. + == Design === Non-Goals diff --git a/examples/server-ktor-db/README.adoc b/examples/server-ktor-db/README.adoc index dbd12e0..d03c8b1 100644 --- a/examples/server-ktor-db/README.adoc +++ b/examples/server-ktor-db/README.adoc @@ -2,6 +2,7 @@ A Ktor server that stores entries in a SQLite database, through a HikariCP pool, Flyway migrations, and Exposed, and traces and measures itself with OpenTelemetry. It is wired three ways, with the same server and config in `common`: `vanilla`, `kodein`, and `metro`. +`jib` builds the vanilla app into a container image, with its JVM AOT cache in it. See the Database and Telemetry sections of the link:../../README.adoc[README] for the modules it uses. == Running it @@ -23,6 +24,27 @@ curl -X PUT --data 'hello' http://localhost:8001/entries/greeting The config is in `common/src/main/resources/application.conf`. +== Starting faster, with an AOT cache + +The `vanilla` app has an `aotCache` task, which runs the installed app once, serving a few requests, to write its JVM AOT cache: + +[source,shell] +---- +./gradlew :examples:server-ktor-db:vanilla:aotCache +cd vanilla +JAVA_OPTS=-XX:AOTCache=build/aot/vanilla.aot build/install/vanilla/bin/vanilla +---- + +The `jib` app builds an image with the cache in it, trained in a container of the image itself: + +[source,shell] +---- +./gradlew :examples:server-ktor-db:jib:jibDockerBuild -PcontainerCli=podman +podman run --rm -p 8001:8001 bootable-examples/server-ktor-db-jib +---- + +See Faster Start in the link:../../README.adoc[README] for how it works, what has to match for the JVM to use the cache, and how much faster it starts. + == Seeing it locally === Metrics From 95c8b885d0b449ecb2fc6ef4696360f1a806c2e3 Mon Sep 17 00:00:00 2001 From: Raman Gupta Date: Tue, 17 Nov 2026 17:59:05 -0500 Subject: [PATCH 4/4] ci: build server-ktor-db with its AOT cache in a Dagger module A Dagger module, in Dang, that builds the vanilla app with Gradle in a JDK 25 container, installs it into a JRE container, trains the AOT cache in a container of that runtime, and adds the cache to the same runtime as the image, so the JDK build and the jars' modification times match by construction. check runs verify, which fails unless the image loads most of its classes from the cache; the image is exported, never pushed. - It follows the Dagger 1.0 beta layout: dagger.toml, dagger.lock, and the module in .dagger/modules. .mise.toml provides the stable CLI, and DAGGER_X_RELEASE has it run v1.0.0-beta.28. - dagger.lock pins the JDK and JRE images by digest. - The build uses Gradle's build cache, in the Gradle user home's cache volume, without turning it on for every build. - The training sends its requests through bash's /dev/tcp, as the JRE image has no curl, and unsets the OTEL_* variables Dagger sets, so the app exports nothing to Dagger's collector, and trains as it runs in production. - The README says when to use it rather than the aotCache task or Jib. --- .../modules/server-ktor-db/dagger-module.toml | 5 + .dagger/modules/server-ktor-db/main.dang | 213 ++++++++++++++++++ .mise.toml | 7 + README.adoc | 70 ++++++ dagger.lock | 12 + dagger.toml | 12 + examples/server-ktor-db/README.adoc | 11 +- 7 files changed, 329 insertions(+), 1 deletion(-) create mode 100644 .dagger/modules/server-ktor-db/dagger-module.toml create mode 100644 .dagger/modules/server-ktor-db/main.dang create mode 100644 dagger.lock create mode 100644 dagger.toml diff --git a/.dagger/modules/server-ktor-db/dagger-module.toml b/.dagger/modules/server-ktor-db/dagger-module.toml new file mode 100644 index 0000000..15c4b57 --- /dev/null +++ b/.dagger/modules/server-ktor-db/dagger-module.toml @@ -0,0 +1,5 @@ +name = "server-ktor-db" +engineVersion = "v1.0.0-beta.28" + +[runtime] + source = "dang" diff --git a/.dagger/modules/server-ktor-db/main.dang b/.dagger/modules/server-ktor-db/main.dang new file mode 100644 index 0000000..1587d76 --- /dev/null +++ b/.dagger/modules/server-ktor-db/main.dang @@ -0,0 +1,213 @@ +""" +Builds the vanilla server-ktor-db example into a container image with its JVM AOT cache, as a CI pipeline. + +The training runs in a container of the runtime image, and the image adds the cache to that same container, so the +JDK build and the jars' sizes and modification times, which the JVM checks before it uses the cache, are the +training's. See the Faster Start section of `README.adoc`. +""" +type ServerKtorDb { + """ + The Bootable checkout, minus build outputs and local caches. + """ + pub source: Directory! + + let requests: String! + let rounds: Int! + + new( + ws: Workspace!, + """ + The training run's requests, one per line: `METHOD PATH`, or `METHOD PATH BODY`, sent to the app's port. + They cover the request path, so the first requests are fast too, not just the start. + """ + requests: String! = """ + PUT /entries/trained by the AOT training run + GET /entries/trained + GET /entries + GET / + GET /metrics + DELETE /entries/trained + """, + """ + How many times the training run sends the requests. + """ + rounds: Int! = 20, + ) { + self.source = ws.directory("/", exclude: [ + "**/build", + "**/.gradle", + "**/.kotlin", + "**/node_modules", + ".git", + ".idea", + ".claude", + ".dagger", + ]) + self.requests = requests + self.rounds = rounds + self + } + + # --------------------------------------------------------------------------------------------------------------- + # Build + # --------------------------------------------------------------------------------------------------------------- + + """ + The build environment with the source checked out, before any Gradle task has run: JDK 25, as `.mise.toml` and + the build's Java toolchain ask for. + """ + pub env: Container! { + container + .from("eclipse-temurin:25-jdk") + .withEnvVariable("GRADLE_USER_HOME", "/cache/gradle") + .withMountedCache("/cache/gradle", cacheVolume("bootable-gradle-user-home")) + .withDirectory("/work/bootable", source) + .withWorkdir("/work/bootable") + } + + """ + The installed app, from Gradle's `installDist`: its start script in `bin`, and its jars in `lib`. + The build cache, in the Gradle user home's cache volume, reuses the task outputs of earlier builds. + """ + pub installed: Directory! { + env + .withExec(["./gradlew", "--no-daemon", "--console=plain", "--build-cache", ":examples:server-ktor-db:vanilla:installDist"]) + .directory("examples/server-ktor-db/vanilla/build/install/vanilla") + } + + # --------------------------------------------------------------------------------------------------------------- + # Image + # --------------------------------------------------------------------------------------------------------------- + + """ + The app installed in the runtime image, a JRE, without an AOT cache. + """ + pub runtime: Container! { + container + .from("eclipse-temurin:25-jre") + .withDirectory("/app", installed) + .withWorkdir("/app") + # the config's database path is relative to the working directory: keep it out of the app's directory + .withEnvVariable("DB_JDBC_PATH", "/tmp/entries.db") + .withExposedPort(8001) + .withDefaultArgs(["/app/bin/vanilla"]) + } + + """ + Starts the app with JAVA_OPTS, waits for "=> Running", sends the training requests, and stops it with SIGTERM, so + the app shuts down as it would in production, and the JVM writes the AOT cache, if asked to, as it exits. + + Dagger sets `OTEL_*` variables in every container, for its own tracing, and forwards what they collect to Dagger + Cloud when the CLI is logged in to it. The script unsets them, so the app exports no telemetry there, and runs with + only its own config: an app that loaded the OTLP exporter would train a cache unlike its production one. + + The JRE image has no curl, so the requests go through bash's `/dev/tcp`. + The script has no brace expansions of shell variables, which Dang would read as its own interpolations. + """ + let startAndStop(ctr: Container!, javaOpts: String!, requests: String!, rounds: Int!): Container! { + ctr + .withEnvVariable("JAVA_OPTS", javaOpts) + .withEnvVariable("TRAINING_REQUESTS", requests) + .withEnvVariable("TRAINING_ROUNDS", `${rounds}`) + .withNewFile("/run/start-and-stop.sh", """ + set -euo pipefail + for var in $(compgen -e | grep -E '^(OTEL_|TRACEPARENT$|TRACESTATE$)' || true); do unset "$var"; done + log=/run/app.log + /app/bin/vanilla > "$log" 2>&1 & + pid=$! + + for _ in $(seq 1200); do + grep -q '=> Running (' "$log" && break + if ! kill -0 "$pid" 2>/dev/null; then echo "the app exited before it was ready"; cat "$log"; exit 1; fi + sleep 0.1 + done + grep -q '=> Running (' "$log" || { echo "the app wasn't ready within 2 minutes"; cat "$log"; exit 1; } + + request() { + local method=$1 path=$2 body=$3 length + length=$(printf %s "$body" | wc -c) + exec 3<>/dev/tcp/127.0.0.1/8001 + printf '%s %s HTTP/1.1\\r\\nHost: localhost\\r\\nConnection: close\\r\\nContent-Length: %d\\r\\n\\r\\n%s' "$method" "$path" "$length" "$body" >&3 + local status + read -r _ status _ <&3 + cat <&3 > /dev/null + exec 3<&- + if [ "$status" -ge 400 ]; then echo "$method $path returned $status"; kill -KILL "$pid"; exit 1; fi + } + + for _ in $(seq "$TRAINING_ROUNDS"); do + # read puts the rest of the line, the body, in its last variable + while read -r method path body; do + [ -n "$method" ] || continue + request "$method" "$path" "$body" + done <<< "$TRAINING_REQUESTS" + done + + kill -TERM "$pid" + wait "$pid" || true + cat "$log" + """) + .withExec(["bash", "/run/start-and-stop.sh"]) + } + + """ + The AOT cache, from a training run of the runtime: the app started with `-XX:AOTCacheOutput`, the training + requests, and SIGTERM. + """ + pub aotCache: File! { + startAndStop(runtime, "-XX:AOTCacheOutput=/run/vanilla.aot", requests, rounds).file("/run/vanilla.aot") + } + + """ + The image: the runtime, with the AOT cache at `/app/aot/vanilla.aot`, and `-XX:AOTCache` in `JAVA_OPTS`. + `image export --path=server-ktor-db.tar` writes it to disk; nothing here publishes it. + """ + pub image: Container! { + runtime + .withFile("/app/aot/vanilla.aot", aotCache) + .withEnvVariable("JAVA_OPTS", "-XX:AOTCache=/app/aot/vanilla.aot") + } + + """ + Starts the image once, and fails unless the JVM loaded at least `minPercent` of the classes of its start from the + AOT cache: a JDK build or class path that doesn't match the training's loads them all anew. + Its `stdout` says how many it loaded from the cache. + """ + pub verify( + minPercent: Int! = 90, + ): Container! { + startAndStop(image, "-XX:AOTCache=/app/aot/vanilla.aot -Xlog:class+load=info:file=/run/class-load.log", "", 0) + .withEnvVariable("MIN_PERCENT", `${minPercent}`) + .withExec(["sh", "-c", """ + shared=$(grep -c 'source: shared objects file' /run/class-load.log) + total=$(grep -c 'class,load' /run/class-load.log) + echo "$shared of $total classes loaded from the AOT cache" + [ $((shared * 100)) -ge $((total * MIN_PERCENT)) ] || { echo "below $MIN_PERCENT%"; exit 1; } + """]) + } + + """ + The pull request check: builds the image, and verifies that it uses its AOT cache. It publishes nothing. + """ + pub check: Void @check { + verify.sync + null + } + + # --------------------------------------------------------------------------------------------------------------- + # Local run + # --------------------------------------------------------------------------------------------------------------- + + """ + The image, on port 8001. `dagger start` runs it and tunnels the port to `localhost`. + """ + @up + pub dev: Service! { + image + .withExposedPort(8001) + .asService(args: ["bash", "-c", """ + for var in $(compgen -e | grep -E '^(OTEL_|TRACEPARENT$|TRACESTATE$)' || true); do unset "$var"; done + exec /app/bin/vanilla + """]) + } +} diff --git a/.mise.toml b/.mise.toml index 33b2c9b..2fa6848 100644 --- a/.mise.toml +++ b/.mise.toml @@ -1,2 +1,9 @@ [tools] java = "temurin-25" +dagger = "0.21.11" + +[env] +# The Dagger module needs the Dagger 1.0 beta. The stable CLI downloads and runs the release named here. +DAGGER_X_RELEASE = "v1.0.0-beta.28" +# Hides the Dagger Cloud signup hint; with no login or DAGGER_CLOUD_TOKEN, Dagger sends no traces anyway. +DAGGER_NO_NAG = "1" diff --git a/README.adoc b/README.adoc index 555e87e..8cb9245 100644 --- a/README.adoc +++ b/README.adoc @@ -480,6 +480,76 @@ The cache adds a 64 MB layer to the image, which used 8,259 of the 8,403 classes The JVM's choice of garbage collector, and so part of what the cache holds, depends on the container's memory and CPUs: train with the same limits the application runs with. +=== In a CI pipeline, with Dagger + +The `server-ktor-db` https://dagger.io[Dagger] module, in `.dagger/modules/server-ktor-db/main.dang`, does the same as a CI pipeline, in containers, with nothing on the host but the `dagger` CLI and a container runtime. +It is written in https://docs.dagger.io/reference/sdks/dang[Dang], Dagger's own language, and needs the Dagger 1.0 beta. +It is one file, with no generated code and no package manager. + +Dagger needs a container runtime: Docker, or Podman with its socket enabled. +`mise install` provides the Dagger CLI. +The module needs the 1.0 beta, which the stable CLI downloads and runs when `DAGGER_X_RELEASE` names it; `.mise.toml` sets that variable. +Without mise, install a stable CLI of 0.21.3 or later, and export `DAGGER_X_RELEASE=v1.0.0-beta.28`. +Bootable sends no traces to Dagger Cloud unless you provide your own `DAGGER_CLOUD_TOKEN` or run `dagger login`. + +[source,bash] +---- +dagger check +dagger api call server-ktor-db image export --path=build/server-ktor-db.tar +podman load -i build/server-ktor-db.tar +---- + +`dagger check` runs every function marked `@check`, which here is `check`. +The other functions are called by name, as `dagger api call server-ktor-db `. + +[cols="1,3"] +|=== +|Function |What it does + +|`check` +|The pull request check: builds the image, and runs `verify`. +Publishes nothing. + +|`installed` +|The app, from Gradle's `installDist`, built in `eclipse-temurin:25-jdk`, with Gradle's user home, and its build cache, in a cache volume. + +|`runtime` +|The app installed in `eclipse-temurin:25-jre`, without a cache. + +|`aot-cache` +|The cache, from a training run of `runtime`: the app started with `-XX:AOTCacheOutput`, then `+=> Running+`, the training requests, and SIGTERM. +`--requests` and `--rounds` change the requests. + +|`image` +|`runtime`, with the cache, and `-XX:AOTCache` in `JAVA_OPTS`. +`image export --path=.tar` writes it to disk. + +|`verify` +|Starts `image`, and fails unless at least `--min-percent`, by default 90, of the classes it loads come from the cache. +`verify stdout` says how many. + +|`dev` +|`image`, on port 8001; `dagger start` runs it, and tunnels the port to `localhost`. + +|`env` +|The build container before Gradle has run. +`dagger api call server-ktor-db env terminal` opens a shell in it. +|=== + +The training runs in a container of `runtime`, and `image` adds the cache to that same container, so the JDK build, and the jars' sizes and modification times, are the training's by construction. +`dagger.lock` pins the JDK and JRE images by digest, so the JDK build only changes when `dagger lock update` moves it, and the cache is trained again with it. + +Dagger sets `OTEL_*` variables in every container, for its own tracing, and forwards what they collect to Dagger Cloud when the CLI is logged in to it. +The module unsets them before it starts the app, which would otherwise export its own telemetry there, and, by loading the OTLP exporter, train a cache unlike the one it uses in production. + +Its image used 8,253 of the 8,400 classes it loaded from its 64 MB cache, and started from launch to `+=> Running+` in a median of 385 ms with the cache, and 860 ms without it, over 7 starts, each in a new container. + +=== Which to use + +* The `aotCache` task, for an application shipped as its installed distribution, or to try the cache locally: it trains on the build's own JDK toolchain, and needs nothing else. +* Jib, for a container image built by Gradle, without a Dockerfile: the training needs a container runtime, to run the image once. +* Dagger, for a CI pipeline that runs the same way on a laptop and on any CI service, where the build, the training and the image are each a cached, containerized step: the host needs only Dagger and a container runtime, not a JDK, and the training runs on the runtime image's JDK by construction. + == Design === Non-Goals diff --git a/dagger.lock b/dagger.lock new file mode 100644 index 0000000..2f32382 --- /dev/null +++ b/dagger.lock @@ -0,0 +1,12 @@ +# Generated by Dagger. Pins the images and git refs this workspace uses. +# Any Dagger command may update this file; always commit it with your changes. +# Run `dagger lock update` to refresh the pinned versions. +[["version","2"]] +["","git-latest",["github.com/dagger/dang-sdk"],"refs/tags/v1.0.1"] +["","git-latest",["github.com/dagger/sdk-helpers",["version","v1"]],"refs/tags/v1.0.11"] +["","git-sha",["github.com/dagger/dang-sdk","refs/tags/v1.0.1"],"6dde4a9ca2cb598bf281ba36778d2428ad53aa48"] +["","git-sha",["github.com/dagger/sdk-helpers","refs/tags/v1.0.11"],"3be7456c40d9206b648ac44e418f30aa79bc6190"] +["","oci-sha",["docker.io/library/eclipse-temurin:25-jdk"],"sha256:884a2f8692cc1e2c7e21f95914adf0ae0eafee9a7eb663a12169cc44468256ec"] +["","oci-sha",["docker.io/library/eclipse-temurin:25-jre"],"sha256:945247f9d092703e0c6be92243ef3c51640229e23ab34d353c8dcdc73e6cd4e6"] +["","vanity-url",["https://dagger.io/sdk/dang"],"https://github.com/dagger/dang-sdk"] +["","vanity-url",["https://dagger.io/sdk/helpers"],"https://github.com/dagger/sdk-helpers"] \ No newline at end of file diff --git a/dagger.toml b/dagger.toml new file mode 100644 index 0000000..5e55e6a --- /dev/null +++ b/dagger.toml @@ -0,0 +1,12 @@ +[modules.dang-sdk] +source = "dagger.io/sdk/dang" + +[sdks.dang] +module = "dang-sdk" + +[modules.server-ktor-db] +source = ".dagger/modules/server-ktor-db" + +[sdks.dang.scopes.".dagger/modules/server-ktor-db"] +is-module = true +name = "server-ktor-db" diff --git a/examples/server-ktor-db/README.adoc b/examples/server-ktor-db/README.adoc index d03c8b1..1870d37 100644 --- a/examples/server-ktor-db/README.adoc +++ b/examples/server-ktor-db/README.adoc @@ -2,7 +2,7 @@ A Ktor server that stores entries in a SQLite database, through a HikariCP pool, Flyway migrations, and Exposed, and traces and measures itself with OpenTelemetry. It is wired three ways, with the same server and config in `common`: `vanilla`, `kodein`, and `metro`. -`jib` builds the vanilla app into a container image, with its JVM AOT cache in it. +`jib` builds the vanilla app into a container image, with its JVM AOT cache in it, and the repository's `server-ktor-db` https://dagger.io[Dagger] module does the same as a CI pipeline. See the Database and Telemetry sections of the link:../../README.adoc[README] for the modules it uses. == Running it @@ -43,6 +43,15 @@ The `jib` app builds an image with the cache in it, trained in a container of th podman run --rm -p 8001:8001 bootable-examples/server-ktor-db-jib ---- +The `server-ktor-db` Dagger module builds the app, trains the cache, and builds the image, each in a container, from anywhere in the repository: + +[source,shell] +---- +dagger check +dagger api call server-ktor-db image export --path=build/server-ktor-db.tar +podman load -i build/server-ktor-db.tar +---- + See Faster Start in the link:../../README.adoc[README] for how it works, what has to match for the JVM to use the cache, and how much faster it starts. == Seeing it locally