@@ -65,7 +65,7 @@ func BenchmarkTPCC(b *testing.B) {
65
65
66
66
// Setup the cluster once for all benchmarks.
67
67
ctx := context .Background ()
68
- tc , pgURL := startCluster (b , ctx )
68
+ tc , pgURLs := startCluster (b , ctx )
69
69
defer tc .Stopper ().Stop (ctx )
70
70
71
71
for _ , impl := range []struct { name , flag string }{
@@ -82,15 +82,15 @@ func BenchmarkTPCC(b *testing.B) {
82
82
{"default" , "--mix=newOrder=10,payment=10,orderStatus=1,delivery=1,stockLevel=1" },
83
83
} {
84
84
b .Run (mix .name , func (b * testing.B ) {
85
- run (b , ctx , pgURL , []string {impl .flag , mix .flag })
85
+ run (b , ctx , pgURLs , []string {impl .flag , mix .flag })
86
86
})
87
87
}
88
88
})
89
89
}
90
90
}
91
91
92
92
// run executes the TPC-C workload with the specified workload flags.
93
- func run (b * testing.B , ctx context.Context , pgURL string , workloadFlags []string ) {
93
+ func run (b * testing.B , ctx context.Context , pgURLs [ nodes ] string , workloadFlags []string ) {
94
94
defer startCPUProfile (b ).Stop (b )
95
95
defer startAllocsProfile (b ).Stop (b )
96
96
@@ -102,7 +102,7 @@ func run(b *testing.B, ctx context.Context, pgURL string, workloadFlags []string
102
102
gen := tpccGenerator (b , flags )
103
103
104
104
reg := histogram .NewRegistry (time .Minute , "tpcc" )
105
- ql , err := gen .Ops (ctx , [] string { pgURL } , reg )
105
+ ql , err := gen .Ops (ctx , pgURLs [:] , reg )
106
106
if err != nil {
107
107
b .Fatal (err )
108
108
}
@@ -119,7 +119,7 @@ func run(b *testing.B, ctx context.Context, pgURL string, workloadFlags []string
119
119
// startCluster starts a cluster and initializes the workload data.
120
120
func startCluster (
121
121
b * testing.B , ctx context.Context ,
122
- ) (_ serverutils.TestClusterInterface , pgURL string ) {
122
+ ) (_ serverutils.TestClusterInterface , pgURLs [ nodes ] string ) {
123
123
st := cluster .MakeTestingClusterSettings ()
124
124
125
125
// NOTE: disabling background work makes the benchmark more predictable, but
@@ -149,8 +149,11 @@ func startCluster(
149
149
})
150
150
151
151
// Generate a PG URL.
152
- u , cleanupURL := tc .ApplicationLayer (0 ).PGUrl (b , serverutils .DBName (dbName ))
153
- tc .Stopper ().AddCloser (stop .CloserFn (cleanupURL ))
152
+ for node := 0 ; node < nodes ; node ++ {
153
+ pgURL , cleanupURL := tc .ApplicationLayer (0 ).PGUrl (b , serverutils .DBName (dbName ))
154
+ pgURLs [node ] = pgURL .String ()
155
+ tc .Stopper ().AddCloser (stop .CloserFn (cleanupURL ))
156
+ }
154
157
155
158
// Create the database.
156
159
r := sqlutils .MakeSQLRunner (tc .ServerConn (0 ))
@@ -164,7 +167,7 @@ func startCluster(
164
167
b .Fatal (err )
165
168
}
166
169
167
- return tc , u . String ()
170
+ return tc , pgURLs
168
171
}
169
172
170
173
type generator interface {
0 commit comments