-
Notifications
You must be signed in to change notification settings - Fork 916
GODRIVER-3102: Perf comparison #2134
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
Changes from 32 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
d2454df
initialize perfcomp module and task
zhouselena e42e875
set up main file
zhouselena 54d4289
cleanup
zhouselena 57f2cba
energy stats algorithm and test
zhouselena 0966d61
apply raw results to energy stats, needs debug
zhouselena bd86386
get stable regions and calc for hscore
zhouselena f49e5b3
Merge branch 'master' of github.com:zhouselena/mongo-go-driver into G…
zhouselena 1ec634f
formatted comment output
zhouselena aac6faf
testing w z-score
zhouselena 5b60b5d
add calc for percent change
zhouselena 8cc29fd
check-modules
zhouselena 3bc9d34
go 1.23
zhouselena 1e161d9
remove toolchain
zhouselena ffe0ff5
try toolchain go 1.23.10
zhouselena 5bedb8d
probably not good
zhouselena 8d4f7a8
cleanup
zhouselena 0cd511e
remove perfcomp from go work
zhouselena 392c835
Merge branch 'master' of github.com:zhouselena/mongo-go-driver into G…
zhouselena e30d8d7
updated performance context
zhouselena 01c7555
changes
zhouselena ffac5da
apply code review changes
zhouselena 00d3ca2
cleanup
zhouselena cd09f22
version ID as args
zhouselena b890d77
changes
zhouselena 97e768d
move energy stats to main.go
zhouselena ee5e23d
move toplevel comment
zhouselena e814f1f
added error propogation for malformed inputs in energy stat calc
zhouselena c50b3ea
Merge branch 'master' of https://github.com/mongodb/mongo-go-driver i…
zhouselena 2a73974
Rename values for clarity
zhouselena 3fd0d39
Handle deferred errors and define findCtx in main
zhouselena 245e3b7
Add project flag to setup framework for other drivers
zhouselena 64a373f
Update shell script with project flag
zhouselena 4707e11
Use tabwriter to align table columns in output
zhouselena f670f33
add context to function signatures
zhouselena 760e4c7
Add check for empty inputs in getEnergyStats
zhouselena 9e48f45
Add todo for project switching
zhouselena c3edd88
Move single benchmark fail logging
zhouselena 3b5cf6d
Merge branch 'master' of github.com:zhouselena/mongo-go-driver into G…
zhouselena a6127dc
Log fatal if energy stats calculation fail
zhouselena 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
# perf-pr-comment | ||
# Generates a report of Go Driver perf changes for the current branch. | ||
|
||
set -eux | ||
|
||
pushd ./internal/cmd/perfcomp >/dev/null || exist | ||
GOWORK=off go run main.go --project="mongo-go-driver" ${VERSION_ID} | ||
popd >/dev/null |
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,93 @@ | ||
// Copyright (C) MongoDB, Inc. 2025-present. | ||
// | ||
// 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 | ||
|
||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"gonum.org/v1/gonum/mat" | ||
) | ||
|
||
func createTestVectors(start1 int, stop1 int, step1 int, start2 int, stop2 int, step2 int) (*mat.Dense, *mat.Dense) { | ||
xData := []float64{} | ||
yData := []float64{} | ||
|
||
for i := start1; i < stop1; i += step1 { | ||
xData = append(xData, float64(i)) | ||
} | ||
for j := start2; j < stop2; j += step2 { | ||
yData = append(yData, float64(j)) | ||
} | ||
|
||
x := mat.NewDense(len(xData), 1, xData) | ||
y := mat.NewDense(len(yData), 1, yData) | ||
|
||
return x, y | ||
} | ||
|
||
func TestEnergyStatistics(t *testing.T) { | ||
|
||
t.Run("similar distributions should have small e,t,h values ", func(t *testing.T) { | ||
x, y := createTestVectors(1, 100, 1, 1, 105, 1) | ||
e, tstat, h, _ := getEnergyStatistics(x, y) | ||
|
||
del := 1e-3 | ||
// Limit precision of comparison to 3 digits after the decimal. | ||
assert.InDelta(t, 0.160, e, del) // |0.160 - e| < 0.001 | ||
assert.InDelta(t, 8.136, tstat, del) | ||
assert.InDelta(t, 0.002, h, del) | ||
}) | ||
|
||
t.Run("different distributions should have large e,t,h values", func(t *testing.T) { | ||
x, y := createTestVectors(1, 100, 1, 10000, 13000, 14) | ||
e, tstat, h, _ := getEnergyStatistics(x, y) | ||
del := 1e-3 | ||
|
||
assert.InDelta(t, 21859.691, e, del) | ||
assert.InDelta(t, 1481794.709, tstat, del) | ||
assert.InDelta(t, 0.954, h, del) | ||
}) | ||
|
||
t.Run("uni-variate distributions", func(t *testing.T) { | ||
x, y := createTestVectors(1, 300, 1, 1000, 5000, 10) | ||
e, tstat, h, _ := getEnergyStatistics(x, y) | ||
del := 1e-3 | ||
|
||
assert.InDelta(t, 4257.009, e, del) | ||
assert.InDelta(t, 728381.015, tstat, del) | ||
assert.InDelta(t, 0.748, h, del) | ||
}) | ||
|
||
t.Run("equal distributions should have all 0 values", func(t *testing.T) { | ||
x := mat.NewDense(10, 1, []float64{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}) | ||
y := mat.NewDense(1, 1, []float64{1}) | ||
|
||
e, tstat, h, _ := getEnergyStatistics(x, y) | ||
|
||
assert.Equal(t, 0.0, e) | ||
assert.Equal(t, 0.0, tstat) | ||
assert.Equal(t, 0.0, h) | ||
}) | ||
|
||
t.Run("energy stats returns errors on malformed input", func(t *testing.T) { | ||
x := mat.NewDense(2, 2, make([]float64, 4)) | ||
y := mat.NewDense(2, 3, make([]float64, 6)) | ||
|
||
_, _, _, err := getEnergyStatistics(x, y) | ||
assert.NotEqual(t, nil, err) | ||
assert.ErrorContains(t, err, "both inputs must have the same number of columns") | ||
|
||
x = mat.NewDense(2, 2, make([]float64, 4)) | ||
y = mat.NewDense(3, 2, make([]float64, 6)) | ||
|
||
_, _, _, err = getEnergyStatistics(x, y) | ||
assert.NotEqual(t, nil, err) | ||
assert.ErrorContains(t, err, "both inputs must be column vectors") | ||
}) | ||
|
||
} |
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,28 @@ | ||
module go.mongodb.go/mongo-driver/v2/internal/cmd/perfcomp | ||
|
||
go 1.23.0 | ||
|
||
toolchain go1.23.10 | ||
|
||
replace go.mongodb.org/mongo-driver/v2 => ../../../ | ||
|
||
require ( | ||
github.com/stretchr/testify v1.10.0 | ||
go.mongodb.org/mongo-driver/v2 v2.2.2 | ||
gonum.org/v1/gonum v0.16.0 | ||
) | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/golang/snappy v1.0.0 // indirect | ||
github.com/klauspost/compress v1.16.7 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/xdg-go/pbkdf2 v1.0.0 // indirect | ||
github.com/xdg-go/scram v1.1.2 // indirect | ||
github.com/xdg-go/stringprep v1.0.4 // indirect | ||
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect | ||
golang.org/x/crypto v0.33.0 // indirect | ||
golang.org/x/sync v0.12.0 // indirect | ||
golang.org/x/text v0.23.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
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,56 @@ | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs= | ||
github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= | ||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= | ||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= | ||
github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= | ||
github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= | ||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= | ||
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= | ||
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= | ||
github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= | ||
github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= | ||
github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= | ||
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= | ||
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= | ||
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= | ||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= | ||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= | ||
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= | ||
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= | ||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= | ||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | ||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= | ||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= | ||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= | ||
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= | ||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= | ||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= | ||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= | ||
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= | ||
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= | ||
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= | ||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | ||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= | ||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= | ||
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
Oops, something went wrong.
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.