- Notifications
You must be signed in to change notification settings - Fork 1.5k
Add BulkWrite Benchmarks #1657
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
Merged
Merged
Add BulkWrite Benchmarks #1657
Changes from 9 commits
Commits
Show all changes
12 commits Select commit Hold shift + click to select a range
5179c30 Add Collection and Client BulkWrite benchmarks.
vbabanin b4ef6c2 Add Mixed Client Bulk Write.
vbabanin f408b4a Remove logs.
vbabanin ea3ce09 Reuse empty filter.
vbabanin 75c519e Update server version.
vbabanin 757fc3b Split perf tests into different tasks.
vbabanin 5e75e44 Update benchmark file paths and parameters
vbabanin a09f89d Remove version 6 perf tests.
vbabanin ebc56b3 Correct comment.
vbabanin 48b7a99 Fix dataset size.
vbabanin 411088a Change modelList size.
vbabanin f5e10e6 Merge branch 'main' into JAVA-5545
vbabanin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions 59 ...enchmarks/src/main/com/mongodb/benchmark/benchmarks/AbstractCollectionWriteBenchmark.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * 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.client.MongoCollection; | ||
| import com.mongodb.client.MongoDatabase; | ||
| | ||
| public abstract class AbstractCollectionWriteBenchmark<T> extends AbstractWriteBenchmark<T> { | ||
| | ||
| protected MongoCollection<T> collection; | ||
| protected MongoDatabase database; | ||
| | ||
| private final String name; | ||
| private final Class<T> clazz; | ||
| | ||
| protected AbstractCollectionWriteBenchmark(final String name, | ||
| final String resourcePath, | ||
| int numIterations, | ||
| int numberDocuments, | ||
| final Class<T> clazz) { | ||
| super(name, resourcePath, numIterations, numberDocuments, clazz); | ||
NathanQingyangXu marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| this.name = name; | ||
| this.clazz = clazz; | ||
| } | ||
| | ||
| @Override | ||
| public void setUp() throws Exception { | ||
| super.setUp(); | ||
| database = client.getDatabase(DATABASE_NAME); | ||
| collection = database.getCollection(COLLECTION_NAME, clazz); | ||
| database.drop(); | ||
| } | ||
| | ||
| @Override | ||
| public void before() throws Exception { | ||
| super.before(); | ||
| collection.drop(); | ||
| } | ||
| | ||
| @Override | ||
| public String getName() { | ||
| return name; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions 50 ...r-benchmarks/src/main/com/mongodb/benchmark/benchmarks/bulk/ClientBulkWriteBenchmark.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /* | ||
| * 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.bulk; | ||
| | ||
| import com.mongodb.benchmark.benchmarks.AbstractCollectionWriteBenchmark; | ||
| import com.mongodb.client.model.bulk.ClientNamespacedInsertOneModel; | ||
| import com.mongodb.client.model.bulk.ClientNamespacedWriteModel; | ||
| | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| | ||
| public class ClientBulkWriteBenchmark<T> extends AbstractCollectionWriteBenchmark<T> { | ||
| private final List<ClientNamespacedInsertOneModel> modelList; | ||
| | ||
| public ClientBulkWriteBenchmark(final String name, final String resourcePath, final int numDocuments, final Class<T> clazz) { | ||
| super(name + " doc Client BulkWrite insert", resourcePath, 1, numDocuments, clazz); | ||
| modelList = new ArrayList<>(numDocuments); | ||
| } | ||
| | ||
| @Override | ||
| public void before() throws Exception { | ||
| super.before(); | ||
| database.createCollection(COLLECTION_NAME); | ||
| | ||
| modelList.clear(); | ||
| for (int i = 0; i < numDocuments; i++) { | ||
| modelList.add(ClientNamespacedWriteModel.insertOne(NAMESPACE, createDocument())); | ||
| } | ||
| } | ||
| | ||
| @Override | ||
| public void run() { | ||
| client.bulkWrite(modelList); | ||
| } | ||
| } |
48 changes: 48 additions & 0 deletions 48 ...nchmarks/src/main/com/mongodb/benchmark/benchmarks/bulk/CollectionBulkWriteBenchmark.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /* | ||
| * 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.bulk; | ||
| | ||
| import com.mongodb.benchmark.benchmarks.AbstractCollectionWriteBenchmark; | ||
| import com.mongodb.client.model.InsertOneModel; | ||
| | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| | ||
| public class CollectionBulkWriteBenchmark<T> extends AbstractCollectionWriteBenchmark<T> { | ||
| private final List<InsertOneModel<T>> modelList; | ||
| | ||
| public CollectionBulkWriteBenchmark(final String name, final String resourcePath, final int numDocuments, final Class<T> clazz) { | ||
| super(name + " doc Collection BulkWrite insert", resourcePath, 1, numDocuments, clazz); | ||
| modelList = new ArrayList<>(numDocuments); | ||
| } | ||
| | ||
| @Override | ||
| public void before() throws Exception { | ||
| super.before(); | ||
| database.createCollection(COLLECTION_NAME); | ||
| modelList.clear(); | ||
| for (int i = 0; i < numDocuments; i++) { | ||
| modelList.add(new InsertOneModel<>((createDocument()))); | ||
| } | ||
| } | ||
| | ||
| @Override | ||
| public void run() { | ||
| collection.bulkWrite(modelList); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stIncMale mentioned that "Perf test setups are different in mixed bulk writes".