Skip to content

Commit 014dbab

Browse files
committed
bench/tpcc: round-robin queries to all three nodes
Release note: None
1 parent 6eb01bd commit 014dbab

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

pkg/bench/tpcc/bench_test.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func BenchmarkTPCC(b *testing.B) {
6565

6666
// Setup the cluster once for all benchmarks.
6767
ctx := context.Background()
68-
tc, pgURL := startCluster(b, ctx)
68+
tc, pgURLs := startCluster(b, ctx)
6969
defer tc.Stopper().Stop(ctx)
7070

7171
for _, impl := range []struct{ name, flag string }{
@@ -82,15 +82,15 @@ func BenchmarkTPCC(b *testing.B) {
8282
{"default", "--mix=newOrder=10,payment=10,orderStatus=1,delivery=1,stockLevel=1"},
8383
} {
8484
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})
8686
})
8787
}
8888
})
8989
}
9090
}
9191

9292
// 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) {
9494
defer startCPUProfile(b).Stop(b)
9595
defer startAllocsProfile(b).Stop(b)
9696

@@ -102,7 +102,7 @@ func run(b *testing.B, ctx context.Context, pgURL string, workloadFlags []string
102102
gen := tpccGenerator(b, flags)
103103

104104
reg := histogram.NewRegistry(time.Minute, "tpcc")
105-
ql, err := gen.Ops(ctx, []string{pgURL}, reg)
105+
ql, err := gen.Ops(ctx, pgURLs[:], reg)
106106
if err != nil {
107107
b.Fatal(err)
108108
}
@@ -119,7 +119,7 @@ func run(b *testing.B, ctx context.Context, pgURL string, workloadFlags []string
119119
// startCluster starts a cluster and initializes the workload data.
120120
func startCluster(
121121
b *testing.B, ctx context.Context,
122-
) (_ serverutils.TestClusterInterface, pgURL string) {
122+
) (_ serverutils.TestClusterInterface, pgURLs [nodes]string) {
123123
st := cluster.MakeTestingClusterSettings()
124124

125125
// NOTE: disabling background work makes the benchmark more predictable, but
@@ -149,8 +149,11 @@ func startCluster(
149149
})
150150

151151
// 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+
}
154157

155158
// Create the database.
156159
r := sqlutils.MakeSQLRunner(tc.ServerConn(0))
@@ -164,7 +167,7 @@ func startCluster(
164167
b.Fatal(err)
165168
}
166169

167-
return tc, u.String()
170+
return tc, pgURLs
168171
}
169172

170173
type generator interface {

0 commit comments

Comments
 (0)