Skip to content

Commit 5a5ee51

Browse files
Sam Kleinmantychoish
authored andcommitted
GODRIVER-115: driver benchmarks and bson benchmarks
Change-Id: I8d8f0ab8c9ca37db39c31855489b792eb255ab4d
1 parent bb548a5 commit 5a5ee51

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2935
-28
lines changed

.evergreen/config.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,14 @@ functions:
240240
241241
AUTH=${AUTH} SSL=${SSL} MONGODB_URI="${MONGODB_URI}" TOPOLOGY=${TOPOLOGY} make evg-test
242242
243+
244+
send-perf-data:
245+
- command: json.send
246+
params:
247+
name: perf
248+
file: src/github.com/mongodb/mongo-go-driver/perf.json
249+
250+
243251
run-enterprise-auth-tests:
244252
- command: shell.exec
245253
type: test
@@ -289,7 +297,8 @@ pre:
289297
post:
290298
- command: gotest.parse_files
291299
params:
292-
files: ["src/github.com/mongodb/mongo-go-driver/test.suite"]
300+
files:
301+
- "src/github.com/mongodb/mongo-go-driver/*.suite"
293302
- func: upload-mo-artifacts
294303
- func: cleanup
295304

@@ -308,6 +317,7 @@ tasks:
308317
vars:
309318
targets: errcheck
310319

320+
311321
- name: sa-lint
312322
tags: ["static-analysis"]
313323
commands:
@@ -322,6 +332,14 @@ tasks:
322332
vars:
323333
targets: vet
324334

335+
- name: perf
336+
tags: ["performance"]
337+
commands:
338+
- func: run-make
339+
vars:
340+
targets: driver-benchmark
341+
- func: send-perf-data
342+
325343
- name: sa-build-examples
326344
tags: ["static-analysis"]
327345
commands:
@@ -510,6 +528,15 @@ buildvariants:
510528
tasks:
511529
- name: ".static-analysis"
512530

531+
- name: perf
532+
display_name: "Performance"
533+
run_on:
534+
- ubuntu1604-test
535+
expansions:
536+
GO_DIST: "/opt/golang/go1.9"
537+
tasks:
538+
- name: ".performance"
539+
513540
- name: build-check
514541
display_name: "Compile Only Checks"
515542
run_on:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ debug
77
.idea
88
*.sublime-project
99
*.sublime-workspace
10+
driver-test-data.tar.gz
11+
perf

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,15 @@ evg-test:
106106
.PHONY: evg-test-auth
107107
evg-test-auth:
108108
go run -tags gssapi ./core/examples/count/main.go -uri $(MONGODB_URI)
109+
110+
# benchmark specific targets and support
111+
perf:driver-test-data.tar.gz
112+
tar -zxf $< $(if $(eq $(UNAME_S),Darwin),-s , --transform=s)/data/perf/
113+
@touch $@
114+
driver-test-data.tar.gz:
115+
curl --retry 5 "https://s3.amazonaws.com/boxes.10gen.com/build/driver-test-data.tar.gz" -o driver-test-data.tar.gz --silent --max-time 120
116+
benchmark:perf
117+
go test $(BUILD_TAGS) -benchmem -bench=. ./benchmark
118+
driver-benchmark:perf
119+
@go run cmd/godriver-benchmark/main.go | tee perf.suite
120+
.PHONY:benchmark driver-benchmark

THIRD-PARTY-NOTICES

Lines changed: 122 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,38 @@ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
8080
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
8181
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
8282

83+
----------------------------------------------------------------------
84+
License notice for github.com/google/go-cmp
85+
----------------------------------------------------------------------
86+
87+
Copyright (c) 2017 The Go Authors. All rights reserved.
88+
89+
Redistribution and use in source and binary forms, with or without
90+
modification, are permitted provided that the following conditions are
91+
met:
92+
93+
* Redistributions of source code must retain the above copyright
94+
notice, this list of conditions and the following disclaimer.
95+
* Redistributions in binary form must reproduce the above
96+
copyright notice, this list of conditions and the following disclaimer
97+
in the documentation and/or other materials provided with the
98+
distribution.
99+
* Neither the name of Google Inc. nor the names of its
100+
contributors may be used to endorse or promote products derived from
101+
this software without specific prior written permission.
102+
103+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
104+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
105+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
106+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
107+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
108+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
109+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
110+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
111+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
112+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
113+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
114+
83115
----------------------------------------------------------------------
84116
License notice for github.com/kr/pretty
85117
----------------------------------------------------------------------
@@ -130,6 +162,32 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
130162
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
131163
THE SOFTWARE.
132164

165+
----------------------------------------------------------------------
166+
License notice for github.com/montanaflynn/stats
167+
----------------------------------------------------------------------
168+
169+
The MIT License (MIT)
170+
171+
Copyright (c) 2014-2015 Montana Flynn (https://anonfunction.com)
172+
173+
Permission is hereby granted, free of charge, to any person obtaining a copy
174+
of this software and associated documentation files (the "Software"), to deal
175+
in the Software without restriction, including without limitation the rights
176+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
177+
copies of the Software, and to permit persons to whom the Software is
178+
furnished to do so, subject to the following conditions:
179+
180+
The above copyright notice and this permission notice shall be included in all
181+
copies or substantial portions of the Software.
182+
183+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
184+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
185+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
186+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
187+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
188+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
189+
SOFTWARE.
190+
133191
----------------------------------------------------------------------
134192
License notice for github.com/pmezard/go-difflib
135193
----------------------------------------------------------------------
@@ -221,6 +279,70 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
221279
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
222280
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
223281

282+
----------------------------------------------------------------------
283+
License notice for golang.org/x/net
284+
----------------------------------------------------------------------
285+
286+
Copyright (c) 2009 The Go Authors. All rights reserved.
287+
288+
Redistribution and use in source and binary forms, with or without
289+
modification, are permitted provided that the following conditions are
290+
met:
291+
292+
* Redistributions of source code must retain the above copyright
293+
notice, this list of conditions and the following disclaimer.
294+
* Redistributions in binary form must reproduce the above
295+
copyright notice, this list of conditions and the following disclaimer
296+
in the documentation and/or other materials provided with the
297+
distribution.
298+
* Neither the name of Google Inc. nor the names of its
299+
contributors may be used to endorse or promote products derived from
300+
this software without specific prior written permission.
301+
302+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
303+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
304+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
305+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
306+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
307+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
308+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
309+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
310+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
311+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
312+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
313+
314+
----------------------------------------------------------------------
315+
License notice for golang.org/x/sync
316+
----------------------------------------------------------------------
317+
318+
Copyright (c) 2009 The Go Authors. All rights reserved.
319+
320+
Redistribution and use in source and binary forms, with or without
321+
modification, are permitted provided that the following conditions are
322+
met:
323+
324+
* Redistributions of source code must retain the above copyright
325+
notice, this list of conditions and the following disclaimer.
326+
* Redistributions in binary form must reproduce the above
327+
copyright notice, this list of conditions and the following disclaimer
328+
in the documentation and/or other materials provided with the
329+
distribution.
330+
* Neither the name of Google Inc. nor the names of its
331+
contributors may be used to endorse or promote products derived from
332+
this software without specific prior written permission.
333+
334+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
335+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
336+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
337+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
338+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
339+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
340+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
341+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
342+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
343+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
344+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
345+
224346
----------------------------------------------------------------------
225347
License notice for gopkg.in/yaml.v2
226348
----------------------------------------------------------------------
@@ -238,30 +360,3 @@ distributed under the License is distributed on an "AS IS" BASIS,
238360
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
239361
See the License for the specific language governing permissions and
240362
limitations under the License.
241-
242-
----------------------------------------------------------------------
243-
License notice for github.com/go-stack/stack
244-
----------------------------------------------------------------------
245-
246-
The MIT License (MIT)
247-
248-
Copyright (c) 2014 Chris Hines
249-
250-
Permission is hereby granted, free of charge, to any person obtaining a copy
251-
of this software and associated documentation files (the "Software"), to deal
252-
in the Software without restriction, including without limitation the rights
253-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
254-
copies of the Software, and to permit persons to whom the Software is
255-
furnished to do so, subject to the following conditions:
256-
257-
The above copyright notice and this permission notice shall be included in all
258-
copies or substantial portions of the Software.
259-
260-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
261-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
262-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
263-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
264-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
265-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
266-
SOFTWARE.
267-

benchmark/bson.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package benchmark
2+
3+
import (
4+
"io/ioutil"
5+
"path/filepath"
6+
7+
"github.com/mongodb/mongo-go-driver/bson"
8+
"github.com/pkg/errors"
9+
)
10+
11+
const (
12+
perfDataDir = "perf"
13+
bsonDataDir = "extended_bson"
14+
flatBSONData = "flat_bson.json"
15+
deepBSONData = "deep_bson.json"
16+
fullBSONData = "full_bson.json"
17+
)
18+
19+
// utility functions for the bson benchmarks
20+
21+
func loadSourceDocument(pathParts ...string) (*bson.Document, error) {
22+
data, err := ioutil.ReadFile(filepath.Join(pathParts...))
23+
if err != nil {
24+
return nil, err
25+
}
26+
doc, err := bson.ParseExtJSONObject(string(data))
27+
if err != nil {
28+
return nil, err
29+
}
30+
31+
if doc.Len() == 0 {
32+
return nil, errors.New("empty bson document")
33+
}
34+
35+
return doc, nil
36+
}
37+
38+
func loadSourceReader(pathParts ...string) (bson.Reader, error) {
39+
doc, err := loadSourceDocument(pathParts...)
40+
if err != nil {
41+
return nil, err
42+
}
43+
raw, err := doc.MarshalBSON()
44+
if err != nil {
45+
return nil, err
46+
}
47+
48+
return bson.Reader(raw), nil
49+
}

0 commit comments

Comments
 (0)