Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ follow semantic versioning; release dates are ISO 8601.
release commit and Central the version is not published, and the job skips the smoke with a
notice. A scenario must now pass against the published version `run.sh` names on every such
pull request, not only at the cut.
- **The JMH benchmarks in `benchmarks.jar` run with quiet logging.** Only the manual harness
applied `logback-benchmark.xml`; a forked JMH JVM found no Logback configuration, fell back to
Logback's default and printed every engine DEBUG line to the console — 32.8 MB of output for one
`CanonicalRender` fork, 22.2 MB for the four `DocxExport.docx` shapes. Every JMH benchmark now
extends `QuietJmhBenchmark`, whose static initializer applies the manual harness's quiet
configuration and initializes Logback before the fork loads anything that logs, so Logback's
start-up is outside every measured region; the same two runs print 6 KB and 19 KB. The logging
was inside the measured region: `CanonicalRender` allocated 333 172 B/op with it and
273 169 B/op without, each `ColdStart` shot 12.5–13.2 % less, and the `table1000` shape of
`DocxExport.docx` 4.8 % less; the other three shapes moved within their error. JMH results
recorded before 2.5.2, the weekly `benchmarks-jmh.yml` series among them, are not comparable
with later ones. `-jvmArgsAppend "-Dgraphcompose.benchmark.logging=debug"` keeps the engine's
logging, as `-Dgraphcompose.benchmark.logging=debug` does for the manual harness.
`JmhQuietLoggingGuardTest` reads `META-INF/BenchmarkList`, the list the JMH runner reads, adds
the `@State` classes the benchmarks take and every `@State` class of the package, and fails for a
class whose initialization leaves the engine's loggers at DEBUG.

## v2.5.1 — 2026-11-22

Expand Down
16 changes: 16 additions & 0 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,22 @@ An `exec:java` run **cannot** fork (the child JVM loses the project classpath),
so always run JMH through the jar. Quote the JMH numbers — not the manual
harness numbers — for any public performance claim.

Every JMH benchmark, and any `@State` class of its own, extends
`QuietJmhBenchmark`, which applies `logback-benchmark.xml` in the forked JVM and
initializes Logback before anything in it logs — the same quiet configuration the
manual harness uses. Without it a fork falls back to Logback's default and prints
the engine's DEBUG lines to the console, tens of megabytes per run, inside the
timed region. `JmhQuietLoggingGuardTest` fails for a benchmark or `@State` class
that does not extend it. To see the engine's logging in a JMH run, pass the
manual harness's switch to the fork:

```bash
java -jar benchmarks/target/benchmarks.jar CanonicalRender -jvmArgsAppend "-Dgraphcompose.benchmark.logging=debug"
```

JMH results from before 2.5.2 were measured with DEBUG logging on and are not
comparable with later ones.

## Roadmap

The 1.7.0 plan (Track C, B3 → B4 → B5 → B6) introduces a sibling JMH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import java.net.URL;
import java.util.Locale;

final class BenchmarkSupport {
/**
* Logging set-up shared by the manual harness and the JMH benchmarks.
*/
public final class BenchmarkSupport {

private static final String BENCHMARK_LOGGING_PROPERTY = "graphcompose.benchmark.logging";
private static final String LOGBACK_CONFIG_PROPERTY = "logback.configurationFile";
Expand All @@ -13,7 +16,13 @@ final class BenchmarkSupport {
private BenchmarkSupport() {
}

static void configureQuietLogging() {
/**
* Points Logback at {@code logback-benchmark.xml} unless the run asked for
* the engine's logging ({@code -Dgraphcompose.benchmark.logging=debug}) or
* chose a configuration itself ({@code -Dlogback.configurationFile}). Takes
* effect only when called before Logback initializes.
*/
public static void configureQuietLogging() {
// Suppress Logback's own bootstrap/status output for benchmark runs.
// This keeps console output focused on the benchmark metrics instead of
// framework initialization noise.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
@Warmup(iterations = 3, time = 2)
@Measurement(iterations = 5, time = 2)
@Fork(1)
public class CanonicalRenderJmhBenchmark {
public class CanonicalRenderJmhBenchmark extends QuietJmhBenchmark {

/**
* Renders the canonical document to PDF bytes and consumes the result so
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
@Warmup(iterations = 3, time = 2)
@Measurement(iterations = 5, time = 2)
@Fork(1)
public class ChartJmhBenchmark {
public class ChartJmhBenchmark extends QuietJmhBenchmark {

/**
* Builds the three-chart document and renders it to PDF bytes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
@Warmup(iterations = 3, time = 2)
@Measurement(iterations = 5, time = 2)
@Fork(1)
public class ChartVariantJmhBenchmark {
public class ChartVariantJmhBenchmark extends QuietJmhBenchmark {

@Param({"grouped-bar", "horizontal-bar", "stacked-bar", "axis-min-bar", "line", "pie", "donut"})
public String variant;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
* The spec/template objects are built in {@link #setUp()} so the measured shot is
* the cold render path, not fixture assembly. Same workloads as the warm benches
* ({@code engine-simple} inline, {@code ModernInvoice}, {@code ModernProfessional})
* so cold and warm numbers are directly comparable.</p>
* so cold and warm numbers are directly comparable. Logback starts in
* {@link QuietJmhBenchmark}'s class initializer, so its start-up is not in the
* shot.</p>
*
* <pre>
* ./mvnw -f benchmarks/pom.xml clean package -DskipTests
Expand All @@ -52,7 +54,7 @@
@Warmup(iterations = 0)
@Measurement(iterations = 1)
@Fork(10)
public class ColdStartJmhBenchmark {
public class ColdStartJmhBenchmark extends QuietJmhBenchmark {

private InvoiceDocumentSpec invoice;
private DocumentTemplate<InvoiceDocumentSpec> invoiceTemplate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
@Warmup(iterations = 3, time = 2)
@Measurement(iterations = 5, time = 2)
@Fork(1)
public class DocxExportJmhBenchmark {
public class DocxExportJmhBenchmark extends QuietJmhBenchmark {

@Param({"small", "report20", "table1000", "images20"})
public String shape;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
@Warmup(iterations = 3, time = 2)
@Measurement(iterations = 5, time = 2)
@Fork(1)
public class IconRampJmhBenchmark {
public class IconRampJmhBenchmark extends QuietJmhBenchmark {

@Param({"8", "32", "128"})
public int iconCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
@Warmup(iterations = 3, time = 2)
@Measurement(iterations = 5, time = 2)
@Fork(1)
public class ImageJmhBenchmark {
public class ImageJmhBenchmark extends QuietJmhBenchmark {

private static final int IMAGES = 12;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
@Warmup(iterations = 3, time = 2)
@Measurement(iterations = 5, time = 2)
@Fork(1)
public class LargeTableJmhBenchmark {
public class LargeTableJmhBenchmark extends QuietJmhBenchmark {

@Param({"100", "500", "1000"})
public int rows;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
@Warmup(iterations = 3, time = 2)
@Measurement(iterations = 5, time = 2)
@Fork(1)
public class MixedShowcaseJmhBenchmark {
public class MixedShowcaseJmhBenchmark extends QuietJmhBenchmark {

private static final int ICONS = 8;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
@Warmup(iterations = 3, time = 2)
@Measurement(iterations = 5, time = 2)
@Fork(1)
public class PaginatedDocumentJmhBenchmark {
public class PaginatedDocumentJmhBenchmark extends QuietJmhBenchmark {

/** Number of sections (drives the page count). */
@Param({"40"})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.demcha.compose.jmh;

import com.demcha.compose.BenchmarkSupport;
import org.slf4j.LoggerFactory;

/**
* Base class of every JMH benchmark and {@code @State} class in this module: it
* applies the quiet benchmark logging before the forked JVM loads anything that
* logs.
*
* <p>Without it a forked benchmark JVM finds no Logback configuration and falls
* back to Logback's default, which prints every {@code DEBUG} line the engine
* emits to the console, inside the measured region. The static initializer here
* runs before the subclass's own static initializer and before any
* {@code @Setup} method (a superclass is always initialized first), so it holds
* however the subclass orders its fields. It also initializes Logback there, so
* a single-shot benchmark does not time Logback reading its configuration.</p>
*
* <p>The opt-outs are the manual harness's, passed to the fork with
* {@code -jvmArgsAppend}: {@code -Dgraphcompose.benchmark.logging=debug} keeps
* the engine's logging, and {@code -Dlogback.configurationFile=...} chooses
* another configuration.</p>
*/
public abstract class QuietJmhBenchmark {

static {
BenchmarkSupport.configureQuietLogging();
LoggerFactory.getILoggerFactory();
}

/**
* Subclass constructor.
*/
protected QuietJmhBenchmark() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
@Warmup(iterations = 3, time = 2)
@Measurement(iterations = 5, time = 2)
@Fork(1)
public class SparklineRampJmhBenchmark {
public class SparklineRampJmhBenchmark extends QuietJmhBenchmark {

private static final DocumentColor ACCENT = DocumentColor.rgb(20, 80, 95);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
@Warmup(iterations = 3, time = 2)
@Measurement(iterations = 5, time = 2)
@Fork(1)
public class SvgJmhBenchmark {
public class SvgJmhBenchmark extends QuietJmhBenchmark {

/** Parsed once so {@code svgIconToNode} measures only the node-build cost. */
private final SvgIcon icon = SvgIcon.parse(SvgBenchmarkFixtures.MULTI_LAYER_ICON_SVG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
@Warmup(iterations = 3, time = 2)
@Measurement(iterations = 5, time = 2)
@Fork(1)
public class TemplateCvJmhBenchmark {
public class TemplateCvJmhBenchmark extends QuietJmhBenchmark {

private CvDocument cv;
private DocumentTemplate<CvDocument> template;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
@Warmup(iterations = 3, time = 2)
@Measurement(iterations = 5, time = 2)
@Fork(1)
public class VectorPaintJmhBenchmark {
public class VectorPaintJmhBenchmark extends QuietJmhBenchmark {

private static final int PATHS = 40;

Expand Down
Loading