Skip to content

Commit eee6f2f

Browse files
authored
fix(benchmarks): rebuild every branch-versioned module before an A/B run (#465)
* fix(benchmarks): rebuild every branch-versioned module before an A/B run The A/B scripts installed only the engine, but the benchmark module resolves render-pdf and templates — plus the templates tests-classifier jar, which is never published — at the branch's own version. Both sides therefore took those two jars from ~/.m2, and whenever the compared branches share a version, which is the normal case for two branches cut from develop, they took the *same* ones: any change in the PDF backend or the templates module measured a delta of exactly zero. A stale backend jar built against the other branch's core could also throw NoSuchMethodError mid-run instead of reporting a number. Both modules are now installed per branch, guarded by the presence of their pom so a pre-split layout, where the root build produces them, still works. Mirrors the install sequence the CI performance job already uses. * docs(benchmarks): say what an A/B run actually rebuilds, and stop compiling render-pdf's tests The A/B section still told readers each branch is rebuilt with install -pl :graph-compose-core "so the benchmark measures that branch's engine" - the sentence the install fix invalidates, and the only place stating what gets rebuilt. render-pdf now installs with -Dmaven.test.skip=true rather than -DskipTests. Only its main jar is needed, but -DskipTests still compiles its whole test tree, so a branch whose render-pdf tests do not compile would abort the entire A/B at the install step with the output sent to /dev/null. templates keeps -DskipTests, because the benchmark resolves its tests-classifier jar and maven.test.skip would not produce one.
1 parent 5c4be1b commit eee6f2f

3 files changed

Lines changed: 43 additions & 4 deletions

File tree

docs/operations/benchmarks.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,12 @@ The wrappers above benchmark whatever is currently checked out. To answer "is
230230
branch B faster or slower than branch A?" fairly on a noisy laptop, use the
231231
dedicated A/B scripts. They **interleave** the two branches (A,B,A,B,…) so
232232
thermal drift averages out, **repeat** each branch and compare **medians**, and
233-
**cool down** between runs. Each branch is rebuilt (`install -pl :graph-compose-core`) before its
234-
runs so the benchmark measures that branch's engine, and untracked benchmark
235-
probes are moved aside around the branch switch so they cannot break the other
236-
branch's compile.
233+
**cool down** between runs. Each branch is rebuilt before its runs so the benchmark measures that branch:
234+
the engine, plus `render-pdf` and `templates`, because the benchmarks module
235+
resolves all three at the branch's own version. Installing only the engine would
236+
leave both sides sharing whichever backend and template jars happened to be in
237+
`~/.m2`. Untracked benchmark probes are moved aside around the branch switch so
238+
they cannot break the other branch's compile.
237239

238240
- **Windows (PowerShell)**`scripts/ab-bench.ps1`, full suite (latency,
239241
throughput, scalability, stress, comparative):

scripts/ab-bench.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,27 @@ build_engine_and_classpath() {
157157
local engine_pl="."
158158
[ -f core/pom.xml ] && engine_pl=":graph-compose-core"
159159
"$MVNW" -B -ntp -DskipTests install -pl "$engine_pl" >/dev/null
160+
# The benchmark also resolves render-pdf and templates (plus the templates
161+
# tests-classifier jar, which is never published) at the branch's own version,
162+
# so those have to be rebuilt per branch as well. Install only the engine and
163+
# both sides resolve the SAME jars from ~/.m2 whenever the two branches share a
164+
# version — the normal case for two branches off develop — so every change in
165+
# the PDF backend or the templates module reports a delta of exactly zero.
166+
# Guarded by existence: a pre-split layout builds them from the root instead.
167+
# render-pdf contributes only its main jar, so skip building its tests too:
168+
# -DskipTests still compiles them, and a branch whose render-pdf tests do not
169+
# compile would abort the whole A/B at the install step with its output sent to
170+
# /dev/null. templates must keep -DskipTests, because the benchmark resolves its
171+
# tests-classifier jar and maven.test.skip would not produce one.
172+
local module
173+
for module in render-pdf templates; do
174+
[ -f "$module/pom.xml" ] || continue
175+
if [ "$module" = "render-pdf" ]; then
176+
"$MVNW" -B -ntp -f "$module/pom.xml" -Dmaven.test.skip=true install >/dev/null
177+
else
178+
"$MVNW" -B -ntp -f "$module/pom.xml" -DskipTests install >/dev/null
179+
fi
180+
done
160181
"$MVNW" -B -ntp -f benchmarks/pom.xml test-compile dependency:build-classpath \
161182
-DincludeScope=test -Dmdep.outputFile=target/benchmark.classpath >/dev/null
162183
CP="benchmarks/target/test-classes${SEP}benchmarks/target/classes${SEP}$(cat benchmarks/target/benchmark.classpath)"

scripts/run-benchmarks.ps1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,22 @@ try {
328328
& $mavenWrapper "-B" "-ntp" "-DskipTests" "install" "-pl" $enginePl
329329
}
330330

331+
# The benchmark also resolves render-pdf and templates (plus the templates
332+
# tests-classifier jar, which is never published) at the branch's own
333+
# version. Installing only the engine leaves those coming from ~/.m2, so an
334+
# A/B between two branches that share a version compares the SAME backend and
335+
# template jars on both sides and reports a delta of exactly zero for any
336+
# change in them. Guarded by existence: a pre-split layout builds them from
337+
# the root instead.
338+
foreach ($module in @('render-pdf', 'templates')) {
339+
$modulePom = Join-Path $repoRoot "$module/pom.xml"
340+
if (Test-Path $modulePom) {
341+
Invoke-LoggedCommand -Name "01-install-$module" -Command {
342+
& $mavenWrapper "-B" "-ntp" "-f" $modulePom "-DskipTests" "install"
343+
}
344+
}
345+
}
346+
331347
Invoke-LoggedCommand -Name "01-build-classpath" -Command {
332348
& $mavenWrapper "-B" "-ntp" "-f" $benchmarksPom "test-compile" "dependency:build-classpath" "-DincludeScope=test" "-Dmdep.outputFile=target/benchmark.classpath"
333349
}

0 commit comments

Comments
 (0)