@@ -10,11 +10,17 @@ Build and test all Java container optimization methods for the Unicorn Store Spr
1010## Usage
1111
1212``` bash
13- ./test-optimizations.sh # Build all images locally
14- ./test-optimizations.sh --deploy # Build, push to ECR, deploy to EKS, measure startup
15- ./test-optimizations.sh --only cds # Build single method
13+ # Full benchmark: clean Docker, build all, deploy to EKS, measure startup, revert to :latest
14+ ./test-optimizations.sh --pre-clean --deploy --revert
15+
16+ # Build all images locally (no deploy)
17+ ./test-optimizations.sh
18+
19+ # Build single method locally
20+ ./test-optimizations.sh --only cds
21+
22+ # Build, push, and deploy single method
1623./test-optimizations.sh --only cds --deploy
17- ./test-optimizations.sh --deploy --revert # Revert to :latest on exit
1824```
1925
2026## Options
@@ -25,30 +31,30 @@ Build and test all Java container optimization methods for the Unicorn Store Spr
2531| ` --deploy ` | Push to ECR, deploy to EKS, measure startup times |
2632| ` --only <method> ` | Build only specified method (partial match: ` cds ` , ` native ` , etc.) |
2733| ` --revert ` | Revert deployment to ` :latest ` on exit (use with ` --deploy ` ) |
34+ | ` --pre-clean ` | Full Docker prune before building (removes all images, containers, volumes, build cache) |
2835
2936## Methods
3037
3138| Tag | Method | Build | Needs DB | Code Change | Notes |
3239| -----| --------| -------| ----------| -------------| -------|
33- | 01-baseline-1cpu | Baseline with 1 CPU | No | No | No | Deploy-only, ~ 10-12s |
34- | 01-baseline-2cpu | Baseline with 2 CPUs | No | No | No | Deploy-only, ~ 6s |
35- | 01-pod-resize | In-place pod resize | No | No | No | Deploy-only, CPU boost controller |
36- | 02-multi-stage | Optimized Dockerfile | Yes | No | No | Baseline build |
37- | 03-jib | Google Jib Maven plugin | Yes | No | No | No Dockerfile |
38- | 04-custom-jre | Custom JRE with jlink | Yes | No | No | Smaller image |
39- | 05-soci | Seekable OCI (lazy loading) | Yes | No | No | SOCI index after push |
40- | 06-cds | Class Data Sharing | Yes | Yes | No | Paketo Buildpacks |
41- | 07-aot | Ahead-of-Time compilation | Yes | Yes | No | Java 25+ AOT cache |
42- | 08-native | GraalVM Native Image | Yes | No | No | Long build time |
43- | 09-crac | Coordinated Restore at Checkpoint | Yes | Yes | Yes | UnicornPublisher swap |
40+ | 01-multi-stage | Baseline with 1 CPU | Yes | No | No | Baseline build + deploy |
41+ | 01-multi-stage-2cpu | Baseline with 2 CPUs | No | No | No | Deploy variant, same image |
42+ | 01-multi-stage-pod-resize | In-place pod resize | No | No | No | Deploy variant, CPU boost controller |
43+ | 02-jib | Google Jib Maven plugin | Yes | No | No | No Dockerfile |
44+ | 03-custom-jre | Custom JRE with jlink | Yes | No | No | Smaller image |
45+ | 04-soci | Seekable OCI (lazy loading) | Yes | No | No | SOCI index after push |
46+ | 05-cds | Class Data Sharing | Yes | Yes | No | Paketo Buildpacks |
47+ | 06-aot | Ahead-of-Time compilation | Yes | Yes | No | Java 25+ AOT cache |
48+ | 07-native | GraalVM Native Image | Yes | No | No | Long build time |
49+ | 08-crac | Coordinated Restore at Checkpoint | Yes | Yes | Yes | UnicornPublisher swap |
4450
4551## Flow
4652
4753### Build-only mode (default)
4854
4955```
5056For each method:
51- 1. Skip if deploy-only (01-baseline-* , 01-pod-resize)
57+ 1. Skip build if deploy variant (01-multi-stage-2cpu , 01-multi-stage -pod-resize)
5258 2. Pre-build hooks (CRaC: swap UnicornPublisher.crac)
5359 3. Start PostgreSQL if needed (CDS, AOT, CRaC) - AWS RDS or local Docker
5460 4. Build image (docker build, mvn jib:dockerBuild, or pack build)
@@ -66,15 +72,15 @@ For each method:
6672│ Start watcher ──────────────────► Initialize results file │
6773│ │
6874│ For each method: │
69- │ Build image (skip for 01-*) │
70- │ Push to ECR (skip for 01-*) │
75+ │ Build image (skip for variants) │
76+ │ Push to ECR (skip for variants) │
7177│ Write to queue ───────────────► Read queue │
7278│ Continue immediately │
73- │ Handle deploy-only methods: │
74- │ 01-baseline-1cpu : set 1 CPU│
75- │ 01-baseline- 2cpu: set 2 CPU│
76- │ 01-pod-resize: install │
77- │ CPU boost controller │
79+ │ Handle deploy variants: │
80+ │ 01-multi-stage : set 1 CPU │
81+ │ 01-multi-stage- 2cpu: 2 CPU │
82+ │ 01-multi-stage- pod-resize: │
83+ │ install CPU boost ctrl │
7884│ Or: kubectl set image :tag │
7985│ Wait for rollout │
8086│ Record startup time │
@@ -103,25 +109,27 @@ All output goes to `/tmp/test-optimizations/` (or `${SCRIPT_DIR}/.test-optimizat
103109
104110### Build-only stdout
105111```
106- Method | Build | Size Local | Time
107- ---------------|-------|------------|------
108- 01-baseline-1cpu | ✅ | N/A | 0s
109- 02-multi-stage | ✅ | 598MB | 45s
110- 06-cds | ✅ | 1.23GB | 2m23s
111- 08-native | ❌ | N/A | 5m30s
112+ Method | Build | Size Local | Time
113+ --------------------------|-------|------------|------
114+ 01-multi-stage | ✅ | 598MB | 45s
115+ 01-multi-stage-2cpu | ✅ | N/A | 0s
116+ 01-multi-stage-pod-resize | ✅ | N/A | 0s
117+ 02-jib | ✅ | 590MB | 30s
118+ 05-cds | ✅ | 1.23GB | 2m23s
119+ 07-native | ❌ | N/A | 5m30s
112120```
113121
114122### Deploy mode results file
115123```
116- Method | Size Local | Size ECR | Build Time | Startup Time
117- -----------------|------------|----------|------------|-------------
118- 01-baseline-1cpu | N/A | N/A | 0s | 10.234 seconds
119- 01-baseline- 2cpu | N/A | N/A | 0s | 6.123 seconds
120- 01-pod-resize | N/A | N/A | 0s | 5.987 seconds
121- 02-multi-stage | 598MB | 580MB | 45s | 10.234 seconds
122- 06 -cds | 1.23GB | 578MB | 2m23s | 3.916 seconds
123- 07 -aot | 1.34GB | 428MB | 56s | 4.0 seconds
124- 09 -crac | 1.1GB | 1.0GB | 3m20s | 0.087 seconds
124+ Method | Size Local | Size ECR | Build Time | Startup Time
125+ -------------------------- |------------|----------|------------|-------------
126+ 01-multi-stage | 598MB | 580MB | 45s | 10.234 seconds
127+ 01-multi-stage- 2cpu | N/A | N/A | 0s | 6.123 seconds
128+ 01-multi-stage- pod-resize | N/A | N/A | 0s | 5.987 seconds
129+ 02-jib | 590MB | 570MB | 30s | 10.100 seconds
130+ 05 -cds | 1.23GB | 578MB | 2m23s | 3.916 seconds
131+ 06 -aot | 1.34GB | 428MB | 56s | 4.0 seconds
132+ 08 -crac | 1.1GB | 1.0GB | 3m20s | 0.087 seconds
125133```
126134
127135## Database Configuration
@@ -137,13 +145,13 @@ The script automatically detects database configuration:
137145
138146## Special Build Methods
139147
140- ### CDS (06 -cds)
148+ ### CDS (05 -cds)
141149Uses Paketo Buildpacks instead of Dockerfile:
142150- Installs ` pack ` CLI if not available
143151- ` BP_JVM_CDS_ENABLED=true ` - creates CDS archive during build
144152- ` BPL_JVM_CDS_ENABLED=true ` - uses CDS archive at runtime
145153
146- ### Pod Resize (01-pod-resize)
154+ ### Pod Resize (01-multi-stage- pod-resize)
147155Installs Kube Startup CPU Boost controller:
148156- Creates ` StartupCPUBoost ` resource with 100% CPU increase
149157- Automatically removes boost when pod becomes ready
@@ -159,7 +167,7 @@ Database credentials are fetched automatically from AWS or use local Docker fall
159167
160168## Notes
161169
162- - Deploy-only methods (01-* ) don't build images, they modify deployment config
170+ - Deploy variants (01-multi-stage-2cpu, 01-multi-stage-pod-resize) use the same 01-multi-stage image
163171- CDS uses Paketo Buildpacks (not Dockerfile) for proper CDS archive creation
164172- Native image may fail on ARM (macOS) - works on x86-64 Linux
165173- CRaC requires x86-64 for ` -XX:CPUFeatures=generic `
0 commit comments