Boost Your Java Builds: How Mvnd Accelerates Maven with GraalVM
Mvnd, the Apache Maven Daemon built with GraalVM, runs as a native executable that eliminates JVM startup overhead, reduces memory usage, and parallelizes module builds, delivering up to several‑fold speed improvements over traditional Maven, as demonstrated with real‑world performance tests and simple installation steps.
What Is Mvnd
Mvnd (Apache Maven Daemon) is a native executable built with GraalVM that speeds up Maven builds. Its design runs a background daemon to avoid launching a new JVM for each build, significantly improving build speed.
Mvnd not only bundles Maven, so no separate Maven installation is needed, but also compiles to a native executable (no Java installation required), resulting in faster startup and lower memory consumption.
Mvnd Advantages
Fast startup : Because Mvnd is a native executable built with GraalVM, it avoids the overhead of starting a new JVM for each build, dramatically reducing startup time.
Low memory usage : As a native executable, Mvnd uses less memory at launch than a traditional JVM, making it especially effective in resource‑constrained environments.
Parallel processing capability : Mvnd defaults to using multiple CPU cores to build modules in parallel, greatly increasing build speed. The number of cores used is determined by the formula Math.max(Runtime.getRuntime().availableProcessors() - 1, 1) .
When using Mvnd, users may encounter issues related to Maven plugins. Mvnd caches class loaders for Maven plugin classes to speed up builds, but it does not cache SNAPSHOT versions of plugins. Therefore, careful management of plugin versions is required to ensure a smooth build process.
Performance Improvement Test
The author tested on the pigx (multi‑module Maven) project, with the following environment:
Chip: M3 Pro
Total cores: 11 (5 performance + 6 efficiency)
Memory: 36 GB
mvnd clean install
<code>mvnd clean install
Building pigx daemon: 28247b49 threads used/hidden/max: 9/0/10 progress: 9/51 17% time: 00:05
[INFO] Total time: 21.399 s (Wall Clock)
[INFO] Finished at: 2024-06-19T22:11:16+08:00</code>Note: The log shows that mvnd dynamically calculates a maximum of 10 thread resources for execution; later we also tested mvn with 10 threads.
mvn clean install
<code>mvn clean install
[INFO] Total time: 01:02 min
[INFO] Finished at: 2024-06-19T22:30:06+08:00</code>Specify 10 Threads
<code>mvn clean install -T 10
[INFO] Total time: 34.137 s (Wall Clock)
[INFO] Finished at: 2024-06-19T22:27:15+08:00
[INFO] ------------------------------------------------------------------------</code>How to Use
Download and unzip : Mvnd Releases
Configure mvnd environment variable
These two steps complete the mvnd installation; by default it includes Maven, so no separate Maven download is needed.
Java Architecture Diary
Committed to sharing original, high‑quality technical articles; no fluff or promotional content.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.