Skip to content

Commit 3e7edc0

Browse files
brunoborgesCopilot
andcommitted
Run CI cold-start benchmark on a separate fresh runner
Phase 3 now runs in its own job (ci-cold-start) on a completely fresh runner. JAR+AOT are built in a build-jar job and passed via artifact, simulating the actions cache restore in deploy workflow. This ensures Python truly has no __pycache__ and Java has no warm OS caches from prior steps. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent bba428c commit 3e7edc0

File tree

1 file changed

+85
-15
lines changed

1 file changed

+85
-15
lines changed

.github/workflows/benchmark.yml

Lines changed: 85 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,6 @@ jobs:
7474
JAR_STEADY=$(avg_runs $STEADY_RUNS java -jar "$JAR")
7575
AOT_STEADY=$(avg_runs $STEADY_RUNS java -XX:AOTCache="$AOT" -jar "$JAR")
7676
77-
# --- Phase 3: CI cold start (no caches, simulates fresh runner) ---
78-
find html-generators -name '__pycache__' -type d -exec rm -rf {} + 2>/dev/null || true
79-
PY_CI=$(measure python3 html-generators/generate.py)
80-
81-
jbang cache clear > /dev/null 2>&1 || true
82-
JBANG_CI=$(measure jbang html-generators/generate.java)
83-
84-
JAR_CI=$(measure java -jar "$JAR")
85-
AOT_CI=$(measure java -XX:AOTCache="$AOT" -jar "$JAR")
86-
8777
# Write to GitHub Actions Job Summary
8878
{
8979
echo "## Benchmark Results — \`$os_name\`"
@@ -106,17 +96,97 @@ jobs:
10696
echo "| **Fat JAR** | ${JAR_STEADY}s |"
10797
echo "| **JBang** | ${JBANG_STEADY}s |"
10898
echo "| **Python** | ${PY_STEADY}s |"
99+
} >> "$GITHUB_STEP_SUMMARY"
100+
101+
# ---------------------------------------------------------------------------
102+
# Phase 3: CI cold start — runs on a completely fresh runner.
103+
# JAR and AOT are built once then passed via artifact, simulating
104+
# the actions cache restore that happens in the deploy workflow.
105+
# Python and JBang start with zero caches, just like real CI.
106+
# ---------------------------------------------------------------------------
107+
build-jar:
108+
strategy:
109+
matrix:
110+
os: [ubuntu-latest, windows-latest, macos-latest]
111+
runs-on: ${{ matrix.os }}
112+
steps:
113+
- uses: actions/checkout@v6
114+
115+
- uses: actions/setup-java@v5
116+
with:
117+
distribution: 'temurin'
118+
java-version: '25'
119+
120+
- uses: jbangdev/setup-jbang@main
121+
122+
- name: Build fat JAR and AOT cache
123+
run: |
124+
jbang export fatjar --force --output html-generators/generate.jar html-generators/generate.java
125+
java -XX:AOTCacheOutput=html-generators/generate.aot -jar html-generators/generate.jar
126+
127+
- name: Upload JAR and AOT
128+
uses: actions/upload-artifact@v4
129+
with:
130+
name: generator-${{ matrix.os }}
131+
path: |
132+
html-generators/generate.jar
133+
html-generators/generate.aot
134+
135+
ci-cold-start:
136+
needs: build-jar
137+
strategy:
138+
matrix:
139+
os: [ubuntu-latest, windows-latest, macos-latest]
140+
runs-on: ${{ matrix.os }}
141+
steps:
142+
- uses: actions/checkout@v6
143+
144+
- uses: actions/setup-java@v5
145+
with:
146+
distribution: 'temurin'
147+
java-version: '25'
148+
149+
- name: Setup Python
150+
uses: actions/setup-python@v5
151+
with:
152+
python-version: '3.13'
153+
154+
- name: Download JAR and AOT
155+
uses: actions/download-artifact@v4
156+
with:
157+
name: generator-${{ matrix.os }}
158+
path: html-generators
159+
160+
- name: CI cold-start benchmark
161+
shell: bash
162+
run: |
163+
os_name="${{ matrix.os }}"
164+
java_ver=$(java -version 2>&1 | head -1 | sed 's/.*"\(.*\)".*/\1/')
165+
snippet_count=$(find content -name '*.json' | wc -l | tr -d ' ')
166+
167+
measure() {
168+
TIMEFORMAT='%R'
169+
local t
170+
t=$( { time "$@" > /dev/null 2>&1; } 2>&1 )
171+
echo "$t"
172+
}
173+
174+
# Everything is cold: no __pycache__, no JBang cache, fresh JVM
175+
PY_CI=$(measure python3 html-generators/generate.py)
176+
JAR_CI=$(measure java -jar html-generators/generate.jar)
177+
AOT_CI=$(measure java -XX:AOTCache=html-generators/generate.aot -jar html-generators/generate.jar)
178+
179+
{
180+
echo "## CI Cold Start — \`$os_name\`"
109181
echo ""
110-
echo "### Phase 3: CI Cold Start (fresh runner, no caches)"
182+
echo "Java $java_ver · $snippet_count snippets"
111183
echo ""
112-
echo "Simulates a CI environment where every run is the first run."
113-
echo "Python has no \`__pycache__\`, JBang has no compilation cache."
114-
echo "Java AOT benefits from the pre-built \`.aot\` file restored from actions cache."
184+
echo "Fresh runner, no caches. JAR and AOT restored from artifact"
185+
echo "(simulates actions cache restore in deploy workflow)."
115186
echo ""
116187
echo "| Method | Time |"
117188
echo "|--------|------|"
118189
echo "| **Fat JAR + AOT** | **${AOT_CI}s** |"
119190
echo "| **Fat JAR** | ${JAR_CI}s |"
120-
echo "| **JBang** | ${JBANG_CI}s |"
121191
echo "| **Python** | ${PY_CI}s |"
122192
} >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)