Skip to content

Commit a3054ba

Browse files
authored
Introduce Netty benchmark suite. (#1647)
JAVA-5813
1 parent 916420d commit a3054ba

19 files changed

+195
-75
lines changed

Diff for: .evergreen/.evg.yml

+17
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,8 @@ functions:
770770
type: test
771771
params:
772772
working_dir: "src"
773+
env:
774+
PROVIDER: ${PROVIDER}
773775
script: |
774776
${PREPARE_SHELL}
775777
PROJECT_DIRECTORY=${PROJECT_DIRECTORY} .evergreen/run-perf-tests.sh
@@ -1550,6 +1552,20 @@ tasks:
15501552
- func: "run perf tests"
15511553
- func: "send dashboard data"
15521554

1555+
- name: "perf-netty"
1556+
tags: [ "perf" ]
1557+
commands:
1558+
- func: "bootstrap mongo-orchestration"
1559+
vars:
1560+
VERSION: "v8.0-perf"
1561+
TOPOLOGY: "server"
1562+
SSL: "nossl"
1563+
AUTH: "noauth"
1564+
- func: "run perf tests"
1565+
vars:
1566+
PROVIDER: "Netty"
1567+
- func: "send dashboard data"
1568+
15531569
- name: "aws-lambda-deployed-task"
15541570
commands:
15551571
- command: ec2.assume_role
@@ -2263,6 +2279,7 @@ buildvariants:
22632279
run_on: rhel90-dbx-perf-large
22642280
tasks:
22652281
- name: "perf"
2282+
- name: "perf-netty"
22662283

22672284
- name: plain-auth-test
22682285
display_name: "PLAIN (LDAP) Auth test"

Diff for: .evergreen/run-perf-tests.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,14 @@ RELATIVE_DIR_PATH="$(dirname "${BASH_SOURCE:-$0}")"
1717
export TEST_PATH="${PROJECT_DIRECTORY}/driver-performance-test-data/"
1818
export OUTPUT_FILE="${PROJECT_DIRECTORY}/results.json"
1919

20+
if [ "${PROVIDER}" = "Netty" ]; then
21+
TASK="driver-benchmarks:runNetty"
22+
else
23+
TASK="driver-benchmarks:run"
24+
fi
25+
2026
start_time=$(date +%s)
21-
./gradlew -Dorg.mongodb.benchmarks.data=${TEST_PATH} -Dorg.mongodb.benchmarks.output=${OUTPUT_FILE} driver-benchmarks:run
27+
./gradlew -Dorg.mongodb.benchmarks.data=${TEST_PATH} -Dorg.mongodb.benchmarks.output=${OUTPUT_FILE} ${TASK}
2228
end_time=$(date +%s)
2329
elapsed_secs=$((end_time-start_time))
2430

Diff for: driver-benchmarks/build.gradle.kts

+13
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,14 @@ sourceSets {
3737
dependencies {
3838
api(project(":driver-sync"))
3939
api(project(":mongodb-crypt"))
40+
41+
implementation(platform(libs.netty.bom))
42+
implementation(libs.bundles.netty)
43+
4044
implementation(libs.logback.classic)
4145
implementation(libs.jmh.core)
4246
annotationProcessor(libs.jmh.generator.annprocess)
47+
4348
}
4449

4550
tasks.register<JavaExec>("jmh") {
@@ -49,6 +54,14 @@ tasks.register<JavaExec>("jmh") {
4954
classpath = sourceSets.main.get().runtimeClasspath
5055
}
5156

57+
tasks.register<JavaExec>("runNetty") {
58+
group = "application"
59+
description = "Run the Netty main class."
60+
mainClass.set("com.mongodb.benchmark.benchmarks.netty.BenchmarkNettyProviderSuite")
61+
classpath = sourceSets["main"].runtimeClasspath
62+
jvmArgs = application.applicationDefaultJvmArgs.toList()
63+
}
64+
5265
tasks.withType<Javadoc>().configureEach {
5366
enabled = false
5467
}

Diff for: driver-benchmarks/src/main/com/mongodb/benchmark/benchmarks/AbstractBsonDocumentBenchmark.java

+1-8
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,14 @@ public abstract class AbstractBsonDocumentBenchmark<T> extends Benchmark {
3434

3535
protected final PowerOfTwoBufferPool bufferPool = PowerOfTwoBufferPool.DEFAULT;
3636
protected final Codec<T> codec;
37-
38-
private final String name;
3937
private final String resourcePath;
4038

4139
protected T document;
4240
protected byte[] documentBytes;
4341
private int fileLength;
4442

4543
public AbstractBsonDocumentBenchmark(final String name, final String resourcePath, final Codec<T> codec) {
46-
this.name = name;
44+
super(name);
4745
this.resourcePath = resourcePath;
4846
this.codec = codec;
4947
}
@@ -58,11 +56,6 @@ public void setUp() throws IOException {
5856
documentBytes = getDocumentAsBuffer(document);
5957
}
6058

61-
@Override
62-
public String getName() {
63-
return name;
64-
}
65-
6659
@Override
6760
public int getBytesPerRun() {
6861
return fileLength * NUM_INTERNAL_ITERATIONS;

Diff for: driver-benchmarks/src/main/com/mongodb/benchmark/benchmarks/AbstractCollectionWriteBenchmark.java

-8
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ public abstract class AbstractCollectionWriteBenchmark<T> extends AbstractWriteB
2424

2525
protected MongoCollection<T> collection;
2626
protected MongoDatabase database;
27-
28-
private final String name;
2927
private final Class<T> clazz;
3028

3129
protected AbstractCollectionWriteBenchmark(final String name,
@@ -34,7 +32,6 @@ protected AbstractCollectionWriteBenchmark(final String name,
3432
int numDocuments,
3533
final Class<T> clazz) {
3634
super(name, resourcePath, numIterations, numDocuments, clazz);
37-
this.name = name;
3835
this.clazz = clazz;
3936
}
4037

@@ -51,9 +48,4 @@ public void before() throws Exception {
5148
super.before();
5249
collection.drop();
5350
}
54-
55-
@Override
56-
public String getName() {
57-
return name;
58-
}
5951
}

Diff for: driver-benchmarks/src/main/com/mongodb/benchmark/benchmarks/AbstractFindBenchmark.java

+1-7
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,17 @@
3232
public abstract class AbstractFindBenchmark<T> extends AbstractMongoBenchmark {
3333
protected MongoCollection<T> collection;
3434

35-
private final String name;
3635
private final String resourcePath;
3736
private final Class<T> clazz;
3837

3938
private int fileLength;
4039

4140
public AbstractFindBenchmark(final String name, final String resourcePath, final Class<T> clazz) {
42-
this.name = name;
41+
super(name);
4342
this.resourcePath = resourcePath;
4443
this.clazz = clazz;
4544
}
4645

47-
@Override
48-
public String getName() {
49-
return name;
50-
}
51-
5246
public void setUp() throws Exception {
5347
super.setUp();
5448
collection = client.getDatabase(DATABASE_NAME).getCollection(COLLECTION_NAME, clazz);

Diff for: driver-benchmarks/src/main/com/mongodb/benchmark/benchmarks/AbstractGridFSBenchmark.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public abstract class AbstractGridFSBenchmark extends AbstractMongoBenchmark {
2727
protected GridFSBucket bucket;
2828
protected byte[] fileBytes;
2929

30-
public AbstractGridFSBenchmark(final String resourcePath) {
30+
public AbstractGridFSBenchmark(final String name, final String resourcePath) {
31+
super(name);
3132
this.resourcePath = resourcePath;
3233
}
3334

Diff for: driver-benchmarks/src/main/com/mongodb/benchmark/benchmarks/AbstractMongoBenchmark.java

+14-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package com.mongodb.benchmark.benchmarks;
1919

20+
import com.mongodb.MongoClientSettings;
2021
import com.mongodb.MongoNamespace;
2122
import com.mongodb.benchmark.framework.Benchmark;
2223
import com.mongodb.client.MongoClient;
@@ -36,17 +37,29 @@ public abstract class AbstractMongoBenchmark extends Benchmark {
3637
protected static final String COLLECTION_NAME = "corpus";
3738
protected static final MongoNamespace NAMESPACE = new MongoNamespace(
3839
AbstractMongoBenchmark.DATABASE_NAME, AbstractMongoBenchmark.COLLECTION_NAME);
40+
protected MongoClientSettings mongoClientSettings;
3941

42+
public AbstractMongoBenchmark(final String name) {
43+
super(name);
44+
}
4045

4146
protected MongoClient client;
4247

4348
public void setUp() throws Exception {
44-
client = MongoClients.create();
49+
if (mongoClientSettings != null) {
50+
client = MongoClients.create(mongoClientSettings);
51+
} else {
52+
client = MongoClients.create();
53+
}
4554
}
4655

4756
@Override
4857
public void tearDown() throws Exception {
4958
client.close();
5059
}
5160

61+
public AbstractMongoBenchmark applyMongoClientSettings(final MongoClientSettings mongoClientSettings) {
62+
this.mongoClientSettings = mongoClientSettings;
63+
return this;
64+
}
5265
}

Diff for: driver-benchmarks/src/main/com/mongodb/benchmark/benchmarks/AbstractWriteBenchmark.java

+1-7
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
public abstract class AbstractWriteBenchmark<T> extends AbstractMongoBenchmark {
2929
protected static final Bson EMPTY_FILTER = Filters.empty();
30-
private final String name;
3130
private final String resourcePath;
3231
private final Class<T> clazz;
3332
private byte[] bytes;
@@ -41,7 +40,7 @@ protected AbstractWriteBenchmark(final String name,
4140
int numInternalIterations,
4241
int numDocuments,
4342
final Class<T> clazz) {
44-
this.name = name;
43+
super(name);
4544
this.resourcePath = resourcePath;
4645
this.clazz = clazz;
4746
this.numInternalIterations = numInternalIterations;
@@ -57,11 +56,6 @@ public void setUp() throws Exception {
5756
document = codec.decode(new JsonReader(new String(bytes, StandardCharsets.UTF_8)), DecoderContext.builder().build());
5857
}
5958

60-
@Override
61-
public String getName() {
62-
return name;
63-
}
64-
6559
protected T createDocument() {
6660
Codec<T> codec = client.getCodecRegistry().get(clazz);
6761
return codec.decode(new JsonReader(new String(bytes, StandardCharsets.UTF_8)), DecoderContext.builder().build());

Diff for: driver-benchmarks/src/main/com/mongodb/benchmark/benchmarks/BenchmarkSuite.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@
3939
@SuppressWarnings({"rawtypes", "unchecked"})
4040
public class BenchmarkSuite {
4141

42-
private static final int NUM_WARMUP_ITERATIONS = 1;
43-
private static final int NUM_ITERATIONS = 100;
44-
private static final int MIN_TIME_SECONDS = 60;
45-
private static final int MAX_TIME_SECONDS = 300;
42+
protected static final int NUM_WARMUP_ITERATIONS = 1;
43+
protected static final int NUM_ITERATIONS = 100;
44+
protected static final int MIN_TIME_SECONDS = 60;
45+
protected static final int MAX_TIME_SECONDS = 300;
4646

47-
private static final Class DOCUMENT_CLASS = Document.class;
48-
private static final IdRemover<Document> ID_REMOVER = document -> document.remove("_id");
49-
private static final Codec<Document> DOCUMENT_CODEC = getDefaultCodecRegistry().get(DOCUMENT_CLASS);
47+
protected static final Class DOCUMENT_CLASS = Document.class;
48+
protected static final IdRemover<Document> ID_REMOVER = document -> document.remove("_id");
49+
protected static final Codec<Document> DOCUMENT_CODEC = getDefaultCodecRegistry().get(DOCUMENT_CLASS);
5050

51-
private static final List<BenchmarkResultWriter> WRITERS = Arrays.asList(
51+
protected static final List<BenchmarkResultWriter> WRITERS = Arrays.asList(
5252
new EvergreenBenchmarkResultWriter());
5353

5454
public static void main(String[] args) throws Exception {
@@ -120,7 +120,7 @@ private static void runMongoCryptBenchMarks() throws InterruptedException {
120120
}
121121
}
122122

123-
private static void runBenchmark(final Benchmark benchmark) throws Exception {
123+
protected static void runBenchmark(final Benchmark benchmark) throws Exception {
124124
long startTime = System.currentTimeMillis();
125125
BenchmarkResult benchmarkResult = new BenchmarkRunner(benchmark, NUM_WARMUP_ITERATIONS, NUM_ITERATIONS, MIN_TIME_SECONDS,
126126
MAX_TIME_SECONDS).run();

Diff for: driver-benchmarks/src/main/com/mongodb/benchmark/benchmarks/GridFSDownloadBenchmark.java

+1-6
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,7 @@ public class GridFSDownloadBenchmark extends AbstractGridFSBenchmark {
2727
private ObjectId fileId;
2828

2929
public GridFSDownloadBenchmark(final String resourcePath) {
30-
super(resourcePath);
31-
}
32-
33-
@Override
34-
public String getName() {
35-
return "GridFS download";
30+
super("GridFS download", resourcePath);
3631
}
3732

3833
@Override

Diff for: driver-benchmarks/src/main/com/mongodb/benchmark/benchmarks/GridFSMultiFileDownloadBenchmark.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.util.concurrent.Executors;
3535
import java.util.concurrent.TimeUnit;
3636

37+
3738
public class GridFSMultiFileDownloadBenchmark extends AbstractMongoBenchmark {
3839

3940
private GridFSBucket bucket;
@@ -43,9 +44,8 @@ public class GridFSMultiFileDownloadBenchmark extends AbstractMongoBenchmark {
4344

4445
private File tempDirectory;
4546

46-
@Override
47-
public String getName() {
48-
return "GridFS multi-file download";
47+
public GridFSMultiFileDownloadBenchmark() {
48+
super("GridFS multi-file download");
4949
}
5050

5151
@Override

Diff for: driver-benchmarks/src/main/com/mongodb/benchmark/benchmarks/GridFSMultiFileUploadBenchmark.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@
3232
import java.util.concurrent.Executors;
3333
import java.util.concurrent.TimeUnit;
3434

35+
3536
public class GridFSMultiFileUploadBenchmark extends AbstractMongoBenchmark {
3637

3738
private MongoDatabase database;
3839
private GridFSBucket bucket;
3940

4041
private ExecutorService fileService;
4142

42-
@Override
43-
public String getName() {
44-
return "GridFS multi-file upload";
43+
public GridFSMultiFileUploadBenchmark() {
44+
super("GridFS multi-file upload");
4545
}
4646

4747
@Override

Diff for: driver-benchmarks/src/main/com/mongodb/benchmark/benchmarks/GridFSUploadBenchmark.java

+1-6
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,7 @@
2222
public class GridFSUploadBenchmark extends AbstractGridFSBenchmark {
2323

2424
public GridFSUploadBenchmark(final String resourcePath) {
25-
super(resourcePath);
26-
}
27-
28-
@Override
29-
public String getName() {
30-
return "GridFS upload";
25+
super("GridFS upload", resourcePath);
3126
}
3227

3328
@Override

Diff for: driver-benchmarks/src/main/com/mongodb/benchmark/benchmarks/MultiFileExportBenchmark.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ public class MultiFileExportBenchmark extends AbstractMongoBenchmark {
5858
private ExecutorService documentReadingService;
5959
private File tempDirectory;
6060

61-
@Override
62-
public String getName() {
63-
return "LDJSON multi-file export";
61+
public MultiFileExportBenchmark() {
62+
super("LDJSON multi-file export");
6463
}
6564

6665
@Override

Diff for: driver-benchmarks/src/main/com/mongodb/benchmark/benchmarks/MultiFileImportBenchmark.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public class MultiFileImportBenchmark extends AbstractMongoBenchmark {
4545
private ExecutorService fileReadingService;
4646
private ExecutorService documentWritingService;
4747

48+
public MultiFileImportBenchmark() {
49+
super("LDJSON multi-file import");
50+
}
51+
4852
@Override
4953
public void setUp() throws Exception {
5054
super.setUp();
@@ -77,12 +81,6 @@ public void tearDown() throws Exception {
7781
super.tearDown();
7882
}
7983

80-
@Override
81-
public String getName() {
82-
return "LDJSON multi-file import";
83-
}
84-
85-
8684
@Override
8785
public void run() throws InterruptedException {
8886
CountDownLatch latch = new CountDownLatch(500);

0 commit comments

Comments
 (0)