Skip to content
Draft
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
17 changes: 17 additions & 0 deletions .evergreen/.evg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,22 @@ tasks:
PROVIDER: "Netty"
- func: "send-dashboard-data"

- name: "perf-pojo-task"
tags: [ "perf" ]
# Benchmark could exceed 1 hour of execution.
exec_timeout_secs: 7200
commands:
- func: "start-mongo-orchestration"
vars:
VERSION: "v8.0-perf"
TOPOLOGY: "server"
SSL: "nossl"
AUTH: "noauth"
- func: "run-perf-tests"
vars:
PROVIDER: "Pojo"
- func: "send-dashboard-data"

- name: "aws-lambda-deployed-task"
commands:
- command: ec2.assume_role
Expand Down Expand Up @@ -2239,6 +2255,7 @@ buildvariants:
tasks:
- name: "perf-task"
- name: "perf-netty-task"
- name: "perf-pojo-task"

- name: plain-auth-test
display_name: "PLAIN (LDAP) Auth test"
Expand Down
12 changes: 7 additions & 5 deletions .evergreen/run-perf-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@
set -o xtrace
set -o errexit

rm -rf driver-performance-test-data
git clone https://github.com/mongodb-labs/driver-performance-test-data.git
cd driver-performance-test-data
BENCHMARKING_DATA="${PROJECT_DIRECTORY}/testing/resources/specifications/source/benchmarking/data"

cd "${BENCHMARKING_DATA}"
tar xf extended_bson.tgz
tar xf parallel.tgz
tar xf single_and_multi_document.tgz
cd ..
cd "${PROJECT_DIRECTORY}"

RELATIVE_DIR_PATH="$(dirname "${BASH_SOURCE:-$0}")"
. "${RELATIVE_DIR_PATH}/setup-env.bash"

export TEST_PATH="${PROJECT_DIRECTORY}/driver-performance-test-data/"
export TEST_PATH="${BENCHMARKING_DATA}/"
export OUTPUT_FILE="${PROJECT_DIRECTORY}/results.json"

if [ "${PROVIDER}" = "Netty" ]; then
TASK="driver-benchmarks:runNetty"
elif [ "${PROVIDER}" = "Pojo" ]; then
TASK="driver-benchmarks:runPojo"
else
TASK="driver-benchmarks:run"
fi
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "specifications"]
path = testing/resources/specifications
url = https://github.com/mongodb/specifications
url = https://github.com/BorisDog/specifications
8 changes: 8 additions & 0 deletions driver-benchmarks/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ tasks.register<JavaExec>("runNetty") {
jvmArgs = application.applicationDefaultJvmArgs.toList()
}

tasks.register<JavaExec>("runPojo") {
group = "application"
description = "Run the POJO benchmark suite."
mainClass.set("com.mongodb.benchmark.benchmarks.PojoBenchmarkSuite")
classpath = sourceSets["main"].runtimeClasspath
jvmArgs = application.applicationDefaultJvmArgs.toList()
}

tasks.withType<Javadoc>().configureEach {
enabled = false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* Copyright 2016-present MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.mongodb.benchmark.benchmarks;

import com.mongodb.MongoClientSettings;
import com.mongodb.benchmark.benchmarks.bulk.ClientBulkWriteBenchmark;
import com.mongodb.benchmark.benchmarks.bulk.CollectionBulkWriteBenchmark;
import com.mongodb.benchmark.benchmarks.bulk.MixedClientBulkWriteBenchmark;
import com.mongodb.benchmark.benchmarks.bulk.MixedCollectionBulkWriteBenchmark;
import com.mongodb.benchmark.benchmarks.pojo.polymorphic.BranchNode;
import com.mongodb.benchmark.benchmarks.pojo.LargeDoc;
import com.mongodb.benchmark.benchmarks.pojo.TreeNode;
import com.mongodb.benchmark.benchmarks.pojo.tweet.Tweet;
import com.mongodb.benchmark.framework.Benchmark;
import com.mongodb.benchmark.framework.BenchmarkResult;
import com.mongodb.benchmark.framework.BenchmarkResultWriter;
import com.mongodb.benchmark.framework.BenchmarkRunner;
import com.mongodb.benchmark.framework.EvergreenBenchmarkResultWriter;
import org.bson.codecs.Codec;
import org.bson.codecs.configuration.CodecRegistry;
import org.bson.codecs.pojo.PojoCodecProvider;

import java.util.Arrays;
import java.util.List;

import static org.bson.codecs.configuration.CodecRegistries.fromProviders;
import static org.bson.codecs.configuration.CodecRegistries.fromRegistries;

@SuppressWarnings({"rawtypes", "unchecked"})
public class PojoBenchmarkSuite {

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;

protected static final CodecRegistry POJO_CODEC_REGISTRY = fromRegistries(
MongoClientSettings.getDefaultCodecRegistry(),
fromProviders(PojoCodecProvider.builder().automatic(true).build())
);

protected static final MongoClientSettings MONGO_CLIENT_SETTINGS = MongoClientSettings.builder()
.codecRegistry(POJO_CODEC_REGISTRY)
.build();

protected static final Class<TreeNode> TREE_NODE_CLASS = TreeNode.class;
protected static final Codec<TreeNode> TREE_NODE_CODEC = POJO_CODEC_REGISTRY.get(TREE_NODE_CLASS);

protected static final Class<BranchNode> BRANCH_NODE_CLASS = BranchNode.class;
protected static final Codec<BranchNode> BRANCH_NODE_CODEC = POJO_CODEC_REGISTRY.get(BRANCH_NODE_CLASS);

protected static final Class<Tweet> TWEET_CLASS = Tweet.class;
protected static final IdRemover<Tweet> TWEET_ID_REMOVER = tweet -> tweet.setId(null);

protected static final Class<LargeDoc> LARGE_DOC_CLASS = LargeDoc.class;
protected static final IdRemover<LargeDoc> LARGE_DOC_ID_REMOVER = doc -> doc.setId(null);

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

public static void main(String[] args) throws Exception {
runBenchmarks();

for (BenchmarkResultWriter writer : WRITERS) {
writer.close();
}
}

private static void runBenchmarks() throws Exception {
runBenchmark(new BsonEncodingBenchmark<>("Deep POJO", "extended_bson/deep_bson.json", TREE_NODE_CODEC));
runBenchmark(new BsonDecodingBenchmark<>("Deep POJO", "extended_bson/deep_bson.json", TREE_NODE_CODEC));
//TODO
// runBenchmark(new BsonEncodingBenchmark<>("Deep POJO Polymorphic", "extended_bson/deep_bson_polymorphic.json", BRANCH_NODE_CODEC));
// runBenchmark(new BsonDecodingBenchmark<>("Deep POJO Polymorphic", "extended_bson/deep_bson_polymorphic.json", BRANCH_NODE_CODEC));

runBenchmark(new FindOneBenchmark<>("single_and_multi_document/tweet.json", TWEET_CLASS)
.applyMongoClientSettings(MONGO_CLIENT_SETTINGS));
runBenchmark(new FindManyBenchmark<>("single_and_multi_document/tweet.json", TWEET_CLASS)
.applyMongoClientSettings(MONGO_CLIENT_SETTINGS));

runBenchmark(new InsertOneBenchmark<>("POJO Small", "./single_and_multi_document/tweet.json", 10_000,
TWEET_CLASS, TWEET_ID_REMOVER).applyMongoClientSettings(MONGO_CLIENT_SETTINGS));
runBenchmark(new InsertOneBenchmark<>("POJO Large", "./single_and_multi_document/large_doc.json", 10,
LARGE_DOC_CLASS, LARGE_DOC_ID_REMOVER).applyMongoClientSettings(MONGO_CLIENT_SETTINGS));

runBenchmark(new InsertManyBenchmark<>("POJO Small", "./single_and_multi_document/tweet.json", 10_000,
TWEET_CLASS).applyMongoClientSettings(MONGO_CLIENT_SETTINGS));
runBenchmark(new InsertManyBenchmark<>("POJO Large", "./single_and_multi_document/large_doc.json", 10,
LARGE_DOC_CLASS).applyMongoClientSettings(MONGO_CLIENT_SETTINGS));

runBenchmark(new CollectionBulkWriteBenchmark<>("POJO Small", "./single_and_multi_document/tweet.json", 10_000,
TWEET_CLASS).applyMongoClientSettings(MONGO_CLIENT_SETTINGS));
runBenchmark(new CollectionBulkWriteBenchmark<>("POJO Large", "./single_and_multi_document/large_doc.json", 10,
LARGE_DOC_CLASS).applyMongoClientSettings(MONGO_CLIENT_SETTINGS));

runBenchmark(new ClientBulkWriteBenchmark<>("POJO Small", "./single_and_multi_document/tweet.json", 10_000,
TWEET_CLASS).applyMongoClientSettings(MONGO_CLIENT_SETTINGS));
runBenchmark(new ClientBulkWriteBenchmark<>("POJO Large", "./single_and_multi_document/large_doc.json", 10,
LARGE_DOC_CLASS).applyMongoClientSettings(MONGO_CLIENT_SETTINGS));

runBenchmark(new MixedCollectionBulkWriteBenchmark<>("./single_and_multi_document/tweet.json", 10_000,
TWEET_CLASS).applyMongoClientSettings(MONGO_CLIENT_SETTINGS));
runBenchmark(new MixedClientBulkWriteBenchmark<>("./single_and_multi_document/tweet.json", 10_000,
TWEET_CLASS).applyMongoClientSettings(MONGO_CLIENT_SETTINGS));
}

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();
long endTime = System.currentTimeMillis();
System.out.println(benchmarkResult.getName() + ": " + (endTime - startTime) / 1000.0);
for (BenchmarkResultWriter writer : WRITERS) {
writer.write(benchmarkResult);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2016-present MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.mongodb.benchmark.benchmarks.pojo;

import org.bson.codecs.pojo.annotations.BsonExtraElements;
import org.bson.codecs.pojo.annotations.BsonId;
import org.bson.types.ObjectId;

import java.util.Map;

public class LargeDoc {
@BsonId
private ObjectId id;

@BsonExtraElements
private Map<String, Object> extraFields;

public LargeDoc() {
}

public ObjectId getId() {
return id;
}

public void setId(ObjectId id) {
this.id = id;
}

public Map<String, Object> getExtraFields() {
return extraFields;
}

public void setExtraFields(Map<String, Object> extraFields) {
this.extraFields = extraFields;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright 2016-present MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.mongodb.benchmark.benchmarks.pojo;

public class TreeNode {
private TreeNode left;
private TreeNode right;
private String leftValue;
private String rightValue;

public TreeNode() {
}

public TreeNode(TreeNode left, TreeNode right) {
this.left = left;
this.right = right;
}

public TreeNode(String leftValue, String rightValue) {
this.leftValue = leftValue;
this.rightValue = rightValue;
}

public TreeNode getLeft() {
return left;
}

public void setLeft(TreeNode left) {
this.left = left;
}

public TreeNode getRight() {
return right;
}

public void setRight(TreeNode right) {
this.right = right;
}

public String getLeftValue() {
return leftValue;
}

public void setLeftValue(String leftValue) {
this.leftValue = leftValue;
}

public String getRightValue() {
return rightValue;
}

public void setRightValue(String rightValue) {
this.rightValue = rightValue;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2016-present MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.mongodb.benchmark.benchmarks.pojo.polymorphic;

import org.bson.codecs.pojo.annotations.BsonDiscriminator;

@BsonDiscriminator(value = "BranchNode", key = "_t")
public class BranchNode extends Node {
private Node left;
private Node right;

public BranchNode() {
}

public Node getLeft() {
return left;
}

public void setLeft(Node left) {
this.left = left;
}

public Node getRight() {
return right;
}

public void setRight(Node right) {
this.right = right;
}
}
Loading