-
Notifications
You must be signed in to change notification settings - Fork 963
[Perf] Fixing race conditions in performance #17296
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 all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
114da4f
context creation
seankane-msft 330a3c5
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-go into…
seankane-msft e40120c
using a test runner
seankane-msft 0d8cf8c
removing old code
seankane-msft 147011a
eliminated last data race
seankane-msft 2baff99
fixing math in opsPerSecond, adding docs
seankane-msft bec296a
adding tables perf test
seankane-msft 3130741
differentiating from context.DeadlineExceeded error
seankane-msft 726deb0
insert entity test
seankane-msft b5586a6
adding list entities test and fixing up some smaller consistency issues
seankane-msft 0a2e4c0
finished tables performance tests
seankane-msft 840c39b
returning initialize string slice
seankane-msft 4212c43
was ignoring an error
seankane-msft abac91d
adding test for atomic float
seankane-msft 0660949
removing atomic float, incrememt -> increment, loop for warmup/testrun
seankane-msft dd8e03b
format check and test fix
seankane-msft 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,173 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| "context" | ||
| "encoding/json" | ||
| "flag" | ||
| "fmt" | ||
| "os" | ||
| "strings" | ||
|
|
||
| "github.com/Azure/azure-sdk-for-go/sdk/azcore" | ||
| "github.com/Azure/azure-sdk-for-go/sdk/data/aztables" | ||
| "github.com/Azure/azure-sdk-for-go/sdk/internal/perf" | ||
| "github.com/Azure/azure-sdk-for-go/sdk/internal/uuid" | ||
| ) | ||
|
|
||
| type batchTestOptions struct { | ||
| fullEDM bool | ||
| clientSharing bool | ||
| count int | ||
| } | ||
|
|
||
| var batchTestOpts batchTestOptions = batchTestOptions{ | ||
| fullEDM: false, | ||
| clientSharing: false, | ||
| count: 100, | ||
| } | ||
|
|
||
| // batchTestRegister is called once per process | ||
| func batchTestRegister() { | ||
| flag.IntVar(&listTestOpts.count, "count", 100, "Number of entities to batch create") | ||
| flag.IntVar(&listTestOpts.count, "c", 100, "Number of entities to batch create") | ||
| flag.BoolVar(&batchTestOpts.fullEDM, "full-edm", false, "whether to use entities that utiliza all EDM types for serialization/deserialization, or only strings. Default is only strings") | ||
| flag.BoolVar(&batchTestOpts.clientSharing, "no-client-share", false, "create one ServiceClient per test instance. Default is to share a single ServiceClient") | ||
| } | ||
|
|
||
| type batchTestGlobal struct { | ||
| perf.PerfTestOptions | ||
| tableName string | ||
| } | ||
|
|
||
| // NewBatchTest is called once per process | ||
| func NewBatchTest(ctx context.Context, options perf.PerfTestOptions) (perf.GlobalPerfTest, error) { | ||
| guid, err := uuid.New() | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| tableName := fmt.Sprintf("table%s", strings.ReplaceAll(guid.String(), "-", "")) | ||
| d := &batchTestGlobal{ | ||
| PerfTestOptions: options, | ||
| tableName: tableName, | ||
| } | ||
|
|
||
| connStr, ok := os.LookupEnv("AZURE_TABLES_CONNECTION_STRING") | ||
| if !ok { | ||
| return nil, fmt.Errorf("the environment variable 'AZURE_TABLES_CONNECTION_STRING' could not be found") | ||
| } | ||
|
|
||
| svcClient, err := aztables.NewServiceClientFromConnectionString(connStr, nil) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| _, err = svcClient.CreateTable(context.Background(), d.tableName, nil) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| return d, nil | ||
| } | ||
|
|
||
| func (d *batchTestGlobal) GlobalCleanup(ctx context.Context) error { | ||
| connStr, ok := os.LookupEnv("AZURE_TABLES_CONNECTION_STRING") | ||
| if !ok { | ||
| return fmt.Errorf("the environment variable 'AZURE_TABLES_CONNECTION_STRING' could not be found") | ||
| } | ||
|
|
||
| svcClient, err := aztables.NewServiceClientFromConnectionString(connStr, nil) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| _, err = svcClient.DeleteTable(context.Background(), d.tableName, nil) | ||
| return err | ||
| } | ||
|
|
||
| type batchEntityPerfTest struct { | ||
| *batchTestGlobal | ||
| perf.PerfTestOptions | ||
| baseEDMEntity aztables.EDMEntity | ||
| baseStringEntity map[string]string | ||
| tableClient *aztables.Client | ||
| } | ||
|
|
||
| // NewPerfTest is called once per goroutine | ||
| func (g *batchTestGlobal) NewPerfTest(ctx context.Context, options *perf.PerfTestOptions) (perf.PerfTest, error) { | ||
| d := &batchEntityPerfTest{ | ||
| batchTestGlobal: g, | ||
| PerfTestOptions: *options, | ||
| } | ||
|
|
||
| connStr, ok := os.LookupEnv("AZURE_TABLES_CONNECTION_STRING") | ||
| if !ok { | ||
| return nil, fmt.Errorf("the environment variable 'AZURE_TABLES_CONNECTION_STRING' could not be found") | ||
| } | ||
|
|
||
| svcClient, err := aztables.NewServiceClientFromConnectionString(connStr, &aztables.ClientOptions{ | ||
| ClientOptions: azcore.ClientOptions{ | ||
| Transport: d.PerfTestOptions.Transporter, | ||
| }, | ||
| }) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| d.tableClient = svcClient.NewClient(g.tableName) | ||
|
|
||
| pk, err := uuid.New() | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| stringEntity["PartitionKey"] = pk.String() | ||
|
|
||
| d.baseStringEntity = stringEntity | ||
|
|
||
| edmEntity := fullEdm | ||
| edmEntity.PartitionKey = pk.String() | ||
| d.baseEDMEntity = edmEntity | ||
|
|
||
| return d, nil | ||
| } | ||
|
|
||
| func (d *batchEntityPerfTest) Run(ctx context.Context) error { | ||
| batch := make([]aztables.TransactionAction, batchTestOpts.count) | ||
|
|
||
| for i := 0; i < batchTestOpts.count; i++ { | ||
|
|
||
| if batchTestOpts.fullEDM { | ||
| d.baseEDMEntity.RowKey = fmt.Sprint(i) | ||
| marshalled, err := json.Marshal(d.baseEDMEntity) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| batch[i] = aztables.TransactionAction{ | ||
| Entity: marshalled, | ||
| ActionType: aztables.TransactionTypeUpdateMerge, | ||
| } | ||
| } else { | ||
| d.baseStringEntity["RowKey"] = fmt.Sprint(i) | ||
| marshalled, err := json.Marshal(d.baseStringEntity) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| batch[i] = aztables.TransactionAction{ | ||
| Entity: marshalled, | ||
| ActionType: aztables.TransactionTypeUpdateMerge, | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| _, err := d.tableClient.SubmitTransaction(ctx, batch, nil) | ||
| return err | ||
| } | ||
|
|
||
| func (*batchEntityPerfTest) Cleanup(ctx context.Context) error { | ||
| return nil | ||
| } | ||
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,20 @@ | ||
| module github.com/Azure/azure-sdk-for-go/sdk/data/aztables/testdata/perf | ||
|
|
||
| go 1.17 | ||
|
|
||
| replace github.com/Azure/azure-sdk-for-go/sdk/internal => ../../../../internal | ||
|
|
||
| require ( | ||
| github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0 | ||
| github.com/Azure/azure-sdk-for-go/sdk/data/aztables v0.6.0 | ||
| github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1 | ||
| ) | ||
|
|
||
| require ( | ||
| github.com/davecgh/go-spew v1.1.1 // indirect | ||
| github.com/pmezard/go-difflib v1.0.0 // indirect | ||
| github.com/stretchr/testify v1.7.0 // indirect | ||
| golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f // indirect | ||
| golang.org/x/text v0.3.7 // indirect | ||
| gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // 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,60 @@ | ||
| github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0 h1:8wVJL0HUP5yDFXvotdewORTw7Yu88JbreWN/mobSvsQ= | ||
| github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM= | ||
| github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.13.0 h1:bLRntPH25SkY1uZ/YZW+dmxNky9r1fAHvDFrzluo+4Q= | ||
| github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.13.0/go.mod h1:TmXReXZ9yPp5D5TBRMTAtyz+UyOl15Py4hL5E5p6igQ= | ||
| github.com/Azure/azure-sdk-for-go/sdk/data/aztables v0.6.0 h1:aSPOq3mqbWTXPSQhXAwgsJas4ZdyapBn+uWA54HZRto= | ||
| github.com/Azure/azure-sdk-for-go/sdk/data/aztables v0.6.0/go.mod h1:fRf7GSd+2fcFo7pa3QndmE29N9ndRxJK4TosS72TpdI= | ||
| github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= | ||
| github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= | ||
| github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
| 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/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= | ||
| github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= | ||
| github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= | ||
| github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= | ||
| github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= | ||
| github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||
| github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= | ||
| github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= | ||
| github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= | ||
| github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= | ||
| github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= | ||
| github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= | ||
| 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/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
| github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= | ||
| github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||
| golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||
| golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= | ||
| golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNmw2api+jEfxLoykJVice/E= | ||
| golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= | ||
| golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | ||
| golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= | ||
| golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | ||
| golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f h1:OfiFi4JbukWwe3lzw+xunroH1mnC1e2Gy5cxNJApiSY= | ||
| golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | ||
| golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
| golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
| golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
| golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
| golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
| golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
| golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0= | ||
| golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
| golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= | ||
| 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.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||
| golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= | ||
| golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= | ||
| golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||
| 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.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | ||
| gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= | ||
| gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= | ||
| gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||
| gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= | ||
| gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
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.