Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Netty benchmark suite. #1647

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
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
17 changes: 17 additions & 0 deletions .evergreen/.evg.yml
Original file line number Diff line number Diff line change
@@ -780,6 +780,8 @@ functions:
type: test
params:
working_dir: "src"
env:
PROVIDER: ${PROVIDER}
script: |
${PREPARE_SHELL}
PROJECT_DIRECTORY=${PROJECT_DIRECTORY} .evergreen/run-perf-tests.sh
@@ -1560,6 +1562,20 @@ tasks:
- func: "run perf tests"
- func: "send dashboard data"

- name: "perf-netty"
tags: [ "perf" ]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "v8.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
@@ -2312,6 +2328,7 @@ buildvariants:
run_on: rhel90-dbx-perf-large
tasks:
- name: "perf"
- name: "perf-netty"

- name: plain-auth-test
display_name: "PLAIN (LDAP) Auth test"
8 changes: 7 additions & 1 deletion .evergreen/run-perf-tests.sh
Original file line number Diff line number Diff line change
@@ -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))

13 changes: 13 additions & 0 deletions driver-benchmarks/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -37,9 +37,14 @@ sourceSets {
dependencies {
api(project(":driver-sync"))
api(project(":mongodb-crypt"))

implementation(platform(libs.netty.bom))
implementation(libs.bundles.netty)

implementation(libs.logback.classic)
implementation(libs.jmh.core)
annotationProcessor(libs.jmh.generator.annprocess)

}

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

tasks.register<JavaExec>("runNetty") {
group = "application"
description = "Run the Netty main class."
mainClass.set("com.mongodb.benchmark.benchmarks.netty.BenchmarkNettyProviderSuite")
classpath = sourceSets["main"].runtimeClasspath
jvmArgs = application.applicationDefaultJvmArgs.toList()
}

tasks.withType<Javadoc>().configureEach {
enabled = false
}
Original file line number Diff line number Diff line change
@@ -34,16 +34,14 @@ 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(name);
this.resourcePath = resourcePath;
this.codec = codec;
}
@@ -58,11 +56,6 @@ public void setUp() throws IOException {
documentBytes = getDocumentAsBuffer(document);
}

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

@Override
public int getBytesPerRun() {
return fileLength * NUM_INTERNAL_ITERATIONS;
Original file line number Diff line number Diff line change
@@ -32,23 +32,17 @@
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;
super(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);
Original file line number Diff line number Diff line change
@@ -27,7 +27,8 @@ public abstract class AbstractGridFSBenchmark extends AbstractMongoBenchmark {
protected GridFSBucket bucket;
protected byte[] fileBytes;

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

Original file line number Diff line number Diff line change
@@ -29,15 +29,14 @@ 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;
super(name);
this.resourcePath = resourcePath;
this.clazz = clazz;
}
@@ -65,11 +64,6 @@ public void before() throws Exception {
collection.drop();
}

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

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

Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@

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;
@@ -33,17 +34,29 @@ 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 String name) {
super(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
@@ -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 {
@@ -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();
Original file line number Diff line number Diff line change
@@ -27,12 +27,7 @@ public class GridFSDownloadBenchmark extends AbstractGridFSBenchmark {
private ObjectId fileId;

public GridFSDownloadBenchmark(final String resourcePath) {
super(resourcePath);
}

@Override
public String getName() {
return "GridFS download";
super("GridFS download", resourcePath);
}

@Override
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;


public class GridFSMultiFileDownloadBenchmark extends AbstractMongoBenchmark {

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

private File tempDirectory;

@Override
public String getName() {
return "GridFS multi-file download";
public GridFSMultiFileDownloadBenchmark() {
super("GridFS multi-file download");
}

@Override
Original file line number Diff line number Diff line change
@@ -32,16 +32,16 @@
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;


public class GridFSMultiFileUploadBenchmark extends AbstractMongoBenchmark {

private MongoDatabase database;
private GridFSBucket bucket;

private ExecutorService fileService;

@Override
public String getName() {
return "GridFS multi-file upload";
public GridFSMultiFileUploadBenchmark() {
super("GridFS multi-file upload");
}

@Override
Original file line number Diff line number Diff line change
@@ -22,12 +22,7 @@
public class GridFSUploadBenchmark extends AbstractGridFSBenchmark {

public GridFSUploadBenchmark(final String resourcePath) {
super(resourcePath);
}

@Override
public String getName() {
return "GridFS upload";
super("GridFS upload", resourcePath);
}

@Override
Original file line number Diff line number Diff line change
@@ -58,9 +58,8 @@ public class MultiFileExportBenchmark extends AbstractMongoBenchmark {
private ExecutorService documentReadingService;
private File tempDirectory;

@Override
public String getName() {
return "LDJSON multi-file export";
public MultiFileExportBenchmark() {
super("LDJSON multi-file export");
}

@Override
Original file line number Diff line number Diff line change
@@ -45,6 +45,10 @@ public class MultiFileImportBenchmark extends AbstractMongoBenchmark {
private ExecutorService fileReadingService;
private ExecutorService documentWritingService;

public MultiFileImportBenchmark() {
super("LDJSON multi-file import");
}

@Override
public void setUp() throws Exception {
super.setUp();
@@ -77,12 +81,6 @@ public void tearDown() throws Exception {
super.tearDown();
}

@Override
public String getName() {
return "LDJSON multi-file import";
}


@Override
public void run() throws InterruptedException {
CountDownLatch latch = new CountDownLatch(500);
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ public class RunCommandBenchmark<T extends Bson> extends AbstractMongoBenchmark
private final T command;

public RunCommandBenchmark(final Codec<T> codec) {
super("Run command");
this.codec = codec;
this.command = createCommand();
}
@@ -43,11 +44,6 @@ public void setUp() throws Exception {
database = client.getDatabase("admin");
}

@Override
public String getName() {
return "Run command";
}

@Override
public void run() {
for (int i = 0; i < NUM_INTERNAL_ITERATIONS; i++) {
Loading
Oops, something went wrong.