Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Introduce Netty benchmark suite.
  • Loading branch information
vbabanin committed Mar 13, 2025
commit d3196d54316d8bd790c7eeac64bfccd8832462f3
19 changes: 19 additions & 0 deletions .evergreen/.evg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,12 @@ functions:
type: test
params:
working_dir: "src"
env:
PROVIDER: ${PROVIDER}
script: |
${PREPARE_SHELL}
echo "Running performance tests provider ${PROVIDER}"
PROVIDER=${PROVIDER}
PROJECT_DIRECTORY=${PROJECT_DIRECTORY} .evergreen/run-perf-tests.sh

"send dashboard data":
Expand Down Expand Up @@ -1559,6 +1563,20 @@ tasks:
- func: "run perf tests"
- func: "send dashboard data"

- name: "netty-perf"
tags: [ "perf" ]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "v6.0-perf"
TOPOLOGY: "server"
SSL: "nossl"
AUTH: "noauth"
- func: "run perf tests"
vars:
PROVIDER: "Netty"
- func: "send dashboard data"

- name: "aws-lambda-deployed-task"
commands:
- command: ec2.assume_role
Expand Down Expand Up @@ -2311,6 +2329,7 @@ buildvariants:
run_on: rhel90-dbx-perf-large
tasks:
- name: "perf"
- name: "netty-perf"

- name: plain-auth-test
display_name: "PLAIN (LDAP) Auth test"
Expand Down
8 changes: 7 additions & 1 deletion .evergreen/run-perf-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ RELATIVE_DIR_PATH="$(dirname "${BASH_SOURCE:-$0}")"
export TEST_PATH="${PROJECT_DIRECTORY}/driver-performance-test-data/"
export OUTPUT_FILE="${PROJECT_DIRECTORY}/results.json"

if [ "${PROVIDER}" = "Netty" ]; then
TASK="driver-benchmarks:runNetty"
else
TASK="driver-benchmarks:run"
fi

start_time=$(date +%s)
./gradlew -Dorg.mongodb.benchmarks.data=${TEST_PATH} -Dorg.mongodb.benchmarks.output=${OUTPUT_FILE} driver-benchmarks:run
./gradlew -Dorg.mongodb.benchmarks.data=${TEST_PATH} -Dorg.mongodb.benchmarks.output=${OUTPUT_FILE} ${TASK}
end_time=$(date +%s)
elapsed_secs=$((end_time-start_time))

8 changes: 8 additions & 0 deletions driver-benchmarks/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ tasks.register("jmh", JavaExec) {
classpath = sourceSets.main.runtimeClasspath
}

tasks.register("runNetty", JavaExec) {
group = 'application'
description = 'Run the Netty main class.'
mainClass = 'com.mongodb.benchmark.benchmarks.netty.BenchmarkNettyProviderSuite'
classpath = sourceSets.main.runtimeClasspath
jvmArgs applicationDefaultJvmArgs
}

javadoc {
enabled = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,20 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Collections;

public abstract class AbstractBsonDocumentBenchmark<T> extends Benchmark {

protected final PowerOfTwoBufferPool bufferPool = PowerOfTwoBufferPool.DEFAULT;
protected final Codec<T> codec;

private final String name;
private final String resourcePath;

protected T document;
protected byte[] documentBytes;
private int fileLength;

public AbstractBsonDocumentBenchmark(final String name, final String resourcePath, final Codec<T> codec) {
this.name = name;
super(Collections.emptyList(), name);
this.resourcePath = resourcePath;
this.codec = codec;
}
Expand All @@ -58,11 +57,6 @@ public void setUp() throws IOException {
documentBytes = getDocumentAsBuffer(document);
}

@Override
public String getName() {
return name;
}

@Override
public int getBytesPerRun() {
return fileLength * NUM_INTERNAL_ITERATIONS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,20 @@
public abstract class AbstractFindBenchmark<T> extends AbstractMongoBenchmark {
protected MongoCollection<T> collection;

private final String name;
private final String resourcePath;
private final Class<T> clazz;

private int fileLength;

public AbstractFindBenchmark(final String name, final String resourcePath, final Class<T> clazz) {
this.name = name;
public AbstractFindBenchmark(final List<String> tags,
final String name,
final String resourcePath,
final Class<T> clazz) {
super(tags, name);
this.resourcePath = resourcePath;
this.clazz = clazz;
}

@Override
public String getName() {
return name;
}

public void setUp() throws Exception {
super.setUp();
collection = client.getDatabase(DATABASE_NAME).getCollection(COLLECTION_NAME, clazz);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@
import com.mongodb.client.gridfs.GridFSBucket;
import com.mongodb.client.gridfs.GridFSBuckets;

import java.util.List;

public abstract class AbstractGridFSBenchmark extends AbstractMongoBenchmark {
private final String resourcePath;
protected MongoDatabase database;
protected GridFSBucket bucket;
protected byte[] fileBytes;

public AbstractGridFSBenchmark(final String resourcePath) {
public AbstractGridFSBenchmark(final List<String> tags,
final String name,
final String resourcePath) {
super(tags, name);
this.resourcePath = resourcePath;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,23 @@
import org.bson.json.JsonReader;

import java.nio.charset.StandardCharsets;
import java.util.List;

public abstract class AbstractInsertBenchmark<T> extends AbstractMongoBenchmark {

protected MongoCollection<T> collection;

private final String name;
private final String resourcePath;
private final Class<T> clazz;
private byte[] bytes;
protected int fileLength;
protected T document;

protected AbstractInsertBenchmark(final String name, final String resourcePath, final Class<T> clazz) {
this.name = name;
protected AbstractInsertBenchmark(final List<String> tags,
final String name,
final String resourcePath,
final Class<T> clazz) {
super(tags, name);
this.resourcePath = resourcePath;
this.clazz = clazz;
}
Expand Down Expand Up @@ -65,11 +68,6 @@ public void before() throws Exception {
collection.drop();
}

@Override
public String getName() {
return name;
}

protected T createDocument() {
Codec<T> codec = collection.getCodecRegistry().get(clazz);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@

package com.mongodb.benchmark.benchmarks;

import com.mongodb.MongoClientSettings;
import com.mongodb.benchmark.framework.Benchmark;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;

import java.util.List;

public abstract class AbstractMongoBenchmark extends Benchmark {

protected static final int GRIDFS_READING_THREAD_POOL_SIZE = 8;
Expand All @@ -33,17 +36,30 @@ public abstract class AbstractMongoBenchmark extends Benchmark {

protected static final String DATABASE_NAME = "perftest";
protected static final String COLLECTION_NAME = "corpus";
protected MongoClientSettings mongoClientSettings;

public AbstractMongoBenchmark(final List<String> tags,
final String name) {
super(tags, name);
}

protected MongoClient client;

public void setUp() throws Exception {
client = MongoClients.create();
if (mongoClientSettings != null) {
client = MongoClients.create(mongoClientSettings);
} else {
client = MongoClients.create();
}
}

@Override
public void tearDown() throws Exception {
client.close();
}

public AbstractMongoBenchmark applyMongoClientSettings(final MongoClientSettings mongoClientSettings) {
this.mongoClientSettings = mongoClientSettings;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@
@SuppressWarnings({"rawtypes", "unchecked"})
public class BenchmarkSuite {

private static final int NUM_WARMUP_ITERATIONS = 1;
private static final int NUM_ITERATIONS = 100;
private static final int MIN_TIME_SECONDS = 60;
private static final int MAX_TIME_SECONDS = 300;
protected static final int NUM_WARMUP_ITERATIONS = 1;
protected static final int NUM_ITERATIONS = 100;
protected static final int MIN_TIME_SECONDS = 60;
protected static final int MAX_TIME_SECONDS = 300;

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

private static final List<BenchmarkResultWriter> WRITERS = Arrays.asList(
protected static final List<BenchmarkResultWriter> WRITERS = Arrays.asList(
new EvergreenBenchmarkResultWriter());

public static void main(String[] args) throws Exception {
Expand Down Expand Up @@ -101,7 +101,7 @@ private static void runMongoCryptBenchMarks() throws InterruptedException {
}
}

private static void runBenchmark(final Benchmark benchmark) throws Exception {
protected static void runBenchmark(final Benchmark benchmark) throws Exception {
long startTime = System.currentTimeMillis();
BenchmarkResult benchmarkResult = new BenchmarkRunner(benchmark, NUM_WARMUP_ITERATIONS, NUM_ITERATIONS, MIN_TIME_SECONDS,
MAX_TIME_SECONDS).run();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,19 @@

import com.mongodb.client.MongoCursor;

import java.util.Collections;
import java.util.List;

public class FindManyBenchmark<T> extends AbstractFindBenchmark<T> {

private static final String TEST_NAME = "Find many and empty the cursor";

public FindManyBenchmark(final String resourcePath, final Class<T> clazz) {
super("Find many and empty the cursor", resourcePath, clazz);
this(Collections.emptyList(), resourcePath, clazz);
}

public FindManyBenchmark(final List<String> tags, final String resourcePath, final Class<T> clazz) {
super(tags, TEST_NAME, resourcePath, clazz);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,19 @@
import org.bson.BsonDocument;
import org.bson.BsonInt32;

import java.util.Collections;
import java.util.List;

public class FindOneBenchmark<T> extends AbstractFindBenchmark<T> {

private static final String TEST_NAME = "Find one by ID";

public FindOneBenchmark(final String resourcePath, Class<T> clazz) {
super("Find one by ID", resourcePath, clazz);
this(Collections.emptyList(), resourcePath, clazz);
}

public FindOneBenchmark(final List<String> tags, final String resourcePath, Class<T> clazz) {
super(tags, TEST_NAME, resourcePath, clazz);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@
import org.bson.types.ObjectId;

import java.io.ByteArrayInputStream;
import java.util.Collections;
import java.util.List;

public class GridFSDownloadBenchmark extends AbstractGridFSBenchmark {
private static final String TEST_NAME = "GridFS download";

private ObjectId fileId;

public GridFSDownloadBenchmark(final String resourcePath) {
super(resourcePath);
public GridFSDownloadBenchmark(final List<String> tags, final String resourcePath) {
super(tags, TEST_NAME, resourcePath);
}

@Override
public String getName() {
return "GridFS download";
public GridFSDownloadBenchmark(final String resourcePath) {
super(Collections.emptyList(), TEST_NAME, resourcePath);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,30 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;


public class GridFSMultiFileDownloadBenchmark extends AbstractMongoBenchmark {

public static final String TEST_NAME = "GridFS multi-file download";
private GridFSBucket bucket;

private ExecutorService gridFSService;
private ExecutorService fileService;

private File tempDirectory;

@Override
public String getName() {
return "GridFS multi-file download";
public GridFSMultiFileDownloadBenchmark(final List<String> tags) {
super(tags, TEST_NAME);
}

public GridFSMultiFileDownloadBenchmark() {
super(Collections.emptyList(), TEST_NAME);
}

@Override
Expand Down
Loading