|
1 | 1 | # Generator Benchmarks |
2 | 2 |
|
3 | | -Performance comparison of the three ways to run the HTML generator, measured on 85 snippets across 10 categories. |
| 3 | +Performance comparison of the four ways to run the HTML generator, measured on 85 snippets across 10 categories. |
4 | 4 |
|
5 | 5 | ## Results |
6 | 6 |
|
7 | 7 | | Method | Cold Start | Warm Average | Notes | |
8 | 8 | |--------|-----------|-------------|-------| |
9 | | -| **Fat JAR** (`java -jar`) | 1.72s | **0.46s** | Fastest warm; no JBang needed | |
| 9 | +| **Fat JAR + AOT** (`java -XX:AOTCache`) | 0.27s | **0.27s** | Fastest; requires one-time cache build | |
| 10 | +| **Fat JAR** (`java -jar`) | 1.72s | 0.46s | No setup needed | |
10 | 11 | | **JBang** (`jbang generate.java`) | 0.96s | 0.77s | Includes JBang overhead | |
11 | 12 | | **Python** (`python3 generate.py`) | 0.17s | 1.37s | Fastest cold start; slowest warm | |
12 | 13 |
|
13 | 14 | - **Cold start**: First run after clearing caches / fresh process |
14 | | -- **Warm average**: Mean of 4 subsequent runs |
| 15 | +- **Warm average**: Mean of 4 subsequent runs (AOT: mean of 5, no cold penalty) |
15 | 16 |
|
16 | 17 | ## Key Takeaways |
17 | 18 |
|
18 | | -- The **fat JAR** is the fastest option for repeated builds — **~40% faster** than JBang and **~3× faster** than Python at warm steady-state |
| 19 | +- The **fat JAR + AOT cache** is the fastest option — **~40% faster** than the plain fat JAR and **~5× faster** than Python |
| 20 | +- The AOT cache eliminates the JVM cold start penalty entirely (0.27s cold = 0.27s warm) |
19 | 21 | - **Python** has the fastest cold start (no JVM boot) but is the slowest overall |
20 | 22 | - **JBang** adds ~0.3s overhead vs the fat JAR due to its launcher and cache lookup |
21 | | -- For CI/CD, the fat JAR is ideal — no JBang installation or dependency caching required |
| 23 | +- For CI/CD, the plain fat JAR is ideal — no AOT build step needed, and still very fast |
| 24 | + |
| 25 | +## AOT Cache Setup |
| 26 | + |
| 27 | +```bash |
| 28 | +# One-time: build the cache (~21 MB, platform-specific) |
| 29 | +./html-generators/build-cds.sh |
| 30 | + |
| 31 | +# Use it |
| 32 | +java -XX:AOTCache=html-generators/generate.aot -jar html-generators/generate.jar |
| 33 | +``` |
| 34 | + |
| 35 | +The AOT cache uses Java 25 CDS (JEP 514/515) to pre-load ~3,300 classes from a training run. It is platform-specific (CPU arch + JDK version) and not committed to git. |
22 | 36 |
|
23 | 37 | ## Environment |
24 | 38 |
|
|
0 commit comments