Upgrade to Spring Boot 3.3

This commit is contained in:
Mark Paluch
2024-03-07 16:09:08 +01:00
parent f7ccf12c73
commit 069c49b57f
10 changed files with 84 additions and 39 deletions

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.springframework.data.benchmark</groupId>
<artifactId>spring-data-benchmark-parent</artifactId>
<version>2.5.0-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
</parent>
<artifactId>spring-data-benchmark-commons</artifactId>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.springframework.data.benchmark</groupId>
<artifactId>spring-data-benchmark-parent</artifactId>
<version>2.5.0-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
</parent>
<artifactId>spring-data-benchmark-mongodb</artifactId>
@@ -34,6 +34,7 @@
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<version>4.12.2</version>
<scope>runtime</scope>
</dependency>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -15,7 +15,8 @@
<parent>
<groupId>org.springframework.data.build</groupId>
<artifactId>spring-data-parent</artifactId>
<version>2.5.0-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
<relativePath/>
</parent>
<modules>
@@ -27,7 +28,7 @@
</modules>
<properties>
<jmh.version>1.19</jmh.version>
<jmh.version>1.37</jmh.version>
</properties>
<dependencyManagement>
@@ -36,7 +37,15 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.5.0-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-bom</artifactId>
<version>2024.0.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@@ -50,19 +59,19 @@
<dependency>
<groupId>com.github.mp911de.microbenchmark-runner</groupId>
<artifactId>microbenchmark-runner-junit4</artifactId>
<version>0.2.0.RELEASE</version>
<version>0.4.0.RELEASE</version>
</dependency>
<dependency>
<groupId>com.github.mp911de.microbenchmark-runner</groupId>
<artifactId>microbenchmark-runner-extras</artifactId>
<version>0.2.0.RELEASE</version>
<version>0.4.0.RELEASE</version>
</dependency>
<dependency>
<groupId>net.minidev</groupId>
<artifactId>json-smart</artifactId>
<version>2.4.4</version>
<version>2.5.0</version>
</dependency>
</dependencies>
@@ -107,10 +116,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.10.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>17</source>
<target>17</target>
<parameters>true</parameters>
</configuration>
</plugin>
@@ -129,8 +138,10 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testSourceDirectory>${project.build.sourceDirectory}</testSourceDirectory>
<testClassesDirectory>${project.build.outputDirectory}</testClassesDirectory>
<testSourceDirectory>${project.build.sourceDirectory}
</testSourceDirectory>
<testClassesDirectory>${project.build.outputDirectory}
</testClassesDirectory>
<excludes>
<exclude>**/AbstractMicrobenchmark.java</exclude>
<exclude>**/*$*.class</exclude>
@@ -140,7 +151,9 @@
<include>**/*Benchmark*</include>
</includes>
<systemPropertyVariables>
<benchmarkReportDir>${project.build.directory}/reports/performance</benchmarkReportDir>
<benchmarkReportDir>
${project.build.directory}/reports/performance
</benchmarkReportDir>
<project.version>${project.version}</project.version>
<git.dirty>${git.dirty}</git.dirty>
<git.commit.id>${git.commit.id}</git.commit.id>
@@ -153,9 +166,15 @@
<repositories>
<repository>
<id>spring-libs-snapshot</id>
<url>https://repo.spring.io/libs-snapshot</url>
<id>spring-snapshot</id>
<url>https://repo.spring.io/snapshot</url>
</repository>
<repository>
<id>spring-milestone</id>
<url>https://repo.spring.io/milestone</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.springframework.data.benchmark</groupId>
<artifactId>spring-data-benchmark-parent</artifactId>
<version>2.5.0-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
</parent>
<artifactId>spring-data-benchmark-redis</artifactId>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.springframework.data.benchmark</groupId>
<artifactId>spring-data-benchmark-parent</artifactId>
<version>2.5.0-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
</parent>
<artifactId>spring-data-benchmark-relational</artifactId>
@@ -54,7 +54,7 @@
</dependency>
<dependency>
<groupId>io.r2dbc</groupId>
<groupId>org.postgresql</groupId>
<artifactId>r2dbc-postgresql</artifactId>
</dependency>

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.data.microbenchmark.r2dbc;
import io.r2dbc.spi.Readable;
import io.r2dbc.spi.Row;
import java.util.function.Function;
@@ -26,7 +27,7 @@ import org.openjdk.jmh.infra.Blackhole;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.data.microbenchmark.common.AbstractMicrobenchmark;
import org.springframework.data.r2dbc.core.DatabaseClient;
import org.springframework.r2dbc.core.DatabaseClient;
/**
* Benchmark for R2DBC and Spring Data R2DBC
@@ -41,7 +42,7 @@ public class R2dbcBenchmark extends AbstractMicrobenchmark {
@Param({ /* "postgres", */ "h2-in-memory" /*, "h2" */ }) String profile;
private DatabaseClient operations;
private Function<Row, Book> mapper;
private Function<Readable, Book> mapper;
private R2dbcBookRepository repository;
@@ -62,7 +63,7 @@ public class R2dbcBenchmark extends AbstractMicrobenchmark {
@Benchmark
public void findByTitle(Blackhole sink) {
sink.consume(operations.execute(BY_TITLE_SQL) //
sink.consume(operations.sql(BY_TITLE_SQL) //
.bind("title", "title0") //
.map(mapper).one() //
.block());
@@ -71,7 +72,7 @@ public class R2dbcBenchmark extends AbstractMicrobenchmark {
@Benchmark
public void findAll(Blackhole sink) {
sink.consume(operations.execute(FIND_ALL_SQL) //
sink.consume(operations.sql(FIND_ALL_SQL) //
.map(mapper) //
.all() //
.collectList() //

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.springframework.data.benchmark</groupId>
<artifactId>spring-data-benchmark-parent</artifactId>
<version>2.5.0-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
</parent>
<artifactId>spring-data-benchmark-support</artifactId>

View File

@@ -31,8 +31,8 @@ import org.openjdk.jmh.annotations.Warmup;
* @author Mark Paluch
* @see Microbenchmark
*/
@Warmup(iterations = 10)
@Measurement(iterations = 10)
@Warmup(iterations = 10, time = 2)
@Measurement(iterations = 10, time = 2)
@Fork(value = 1, jvmArgs = { "-server", "-XX:+HeapDumpOnOutOfMemoryError", "-Xms1024m", "-Xmx1024m",
"-XX:MaxDirectMemorySize=1024m", "-noverify" })
@State(Scope.Thread)

View File

@@ -16,10 +16,13 @@
package org.springframework.data.microbenchmark.common;
import jmh.mbr.core.ResultsWriter;
import jmh.mbr.core.model.BenchmarkResults;
import lombok.RequiredArgsConstructor;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
@@ -27,14 +30,17 @@ import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.Collection;
import lombok.SneakyThrows;
import org.openjdk.jmh.results.RunResult;
import org.openjdk.jmh.results.format.ResultFormatFactory;
import org.openjdk.jmh.results.format.ResultFormatType;
import org.openjdk.jmh.runner.format.OutputFormat;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.util.CollectionUtils;
/**
* {@link ResultsWriterOld} implementation of {@link URLConnection}.
*
*
* @author Christoph Strobl
* @author Mark Paluch
*/
@@ -43,17 +49,18 @@ class HttpResultsWriter implements ResultsWriter {
private final String url;
@Override
public void write(OutputFormat output, Collection<RunResult> results) {
if (CollectionUtils.isEmpty(results)) {
@Override
public void write(OutputFormat output, BenchmarkResults benchmarkResults) {
if (CollectionUtils.isEmpty(benchmarkResults.getRawResults())) {
return;
}
try {
doWrite(results);
doWrite(benchmarkResults.getRawResults());
} catch (IOException e) {
output.println("Failed to write results: " + e.toString());
output.println("Failed to write results: " + e);
}
}
@@ -79,7 +86,7 @@ class HttpResultsWriter implements ResultsWriter {
connection.addRequestProperty("X-Git-Commit-Id", gitCommitId);
try (OutputStream output = connection.getOutputStream()) {
output.write(ResultsWriter.jsonifyResults(results).getBytes(StandardCharsets.UTF_8));
output.write(jsonifyResults(results).getBytes(StandardCharsets.UTF_8));
}
if (connection.getResponseCode() >= 400) {
@@ -87,4 +94,20 @@ class HttpResultsWriter implements ResultsWriter {
String.format("Status %d %s", connection.getResponseCode(), connection.getResponseMessage()));
}
}
/**
* Convert {@link RunResult}s to JMH Json representation.
*
* @param results
* @return json string representation of results.
* @see org.openjdk.jmh.results.format.JSONResultFormat
*/
@SneakyThrows
static String jsonifyResults(Collection<RunResult> results) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ResultFormatFactory.getInstance(ResultFormatType.JSON, new PrintStream(baos, true, "UTF-8")).writeOut(results);
return new String(baos.toByteArray(), StandardCharsets.UTF_8);
}
}

View File

@@ -16,6 +16,7 @@
package org.springframework.data.microbenchmark.common;
import jmh.mbr.core.ResultsWriter;
import jmh.mbr.core.model.BenchmarkResults;
import lombok.RequiredArgsConstructor;
import net.minidev.json.JSONArray;
import net.minidev.json.JSONObject;
@@ -52,14 +53,14 @@ class MongoResultsWriter implements ResultsWriter {
private final String uri;
@Override
public void write(OutputFormat output, Collection<RunResult> results) {
public void write(OutputFormat output, BenchmarkResults benchmarkResults) {
if (CollectionUtils.isEmpty(results)) {
if (CollectionUtils.isEmpty(benchmarkResults.getRawResults())) {
return;
}
try {
doWrite(results);
doWrite(benchmarkResults.getRawResults());
} catch (ParseException | RuntimeException e) {
output.println("Failed to write results: " + e.toString());
}
@@ -81,7 +82,7 @@ class MongoResultsWriter implements ResultsWriter {
String dbName = StringUtils.hasText(uri.getDatabase()) ? uri.getDatabase() : "spring-data-mongodb-benchmarks";
MongoDatabase db = client.getDatabase(dbName);
String resultsJson = ResultsWriter.jsonifyResults(results).trim();
String resultsJson = HttpResultsWriter.jsonifyResults(results).trim();
JSONArray array = (JSONArray) new JSONParser(JSONParser.MODE_PERMISSIVE).parse(resultsJson);
for (Object object : array) {
JSONObject dbo = (JSONObject) object;