Skip to content

Commit 0437abf

Browse files
committed
bench/tpcc: use import data loader
Using the import data loader instead of the insert data loader speeds up the setup time for the benchmark significantly. Release note: None
1 parent 014dbab commit 0437abf

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

pkg/bench/tpcc/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ go_test(
99
data = glob(["testdata/**"]),
1010
deps = [
1111
"//pkg/base",
12+
"//pkg/ccl/workloadccl",
1213
"//pkg/rpc/nodedialer",
1314
"//pkg/security/securityassets",
1415
"//pkg/security/securitytest",

pkg/bench/tpcc/bench_test.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ package tpcc
88
import (
99
"bytes"
1010
"context"
11+
gosql "database/sql"
1112
"flag"
13+
"fmt"
1214
"io"
1315
"os"
1416
"path/filepath"
@@ -20,6 +22,7 @@ import (
2022
"time"
2123

2224
"github.com/cockroachdb/cockroach/pkg/base"
25+
"github.com/cockroachdb/cockroach/pkg/ccl/workloadccl"
2326
"github.com/cockroachdb/cockroach/pkg/rpc/nodedialer"
2427
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
2528
"github.com/cockroachdb/cockroach/pkg/sql/stats"
@@ -139,6 +142,7 @@ func startCluster(
139142
TestingNoLocalClientOptimization: true,
140143
},
141144
},
145+
SQLMemoryPoolSize: 1 << 30, // 1 GiB
142146
}
143147
}
144148

@@ -148,7 +152,7 @@ func startCluster(
148152
ParallelStart: true,
149153
})
150154

151-
// Generate a PG URL.
155+
// Generate PG URLs.
152156
for node := 0; node < nodes; node++ {
153157
pgURL, cleanupURL := tc.ApplicationLayer(0).PGUrl(b, serverutils.DBName(dbName))
154158
pgURLs[node] = pgURL.String()
@@ -162,11 +166,20 @@ func startCluster(
162166

163167
// Load the TPC-C workload data.
164168
gen := tpccGenerator(b, []string{"--db=" + dbName})
165-
var loader workloadsql.InsertsDataLoader
166-
if _, err := workloadsql.Setup(ctx, tc.ServerConn(0), gen, loader); err != nil {
169+
var loader workloadccl.ImportDataLoader
170+
sqlDB, err := gosql.Open(`cockroach`, strings.Join(pgURLs[:], " "))
171+
if err != nil {
172+
b.Fatal(err)
173+
}
174+
if _, err := workloadsql.Setup(ctx, sqlDB, gen, loader); err != nil {
167175
b.Fatal(err)
168176
}
169177

178+
// Collect stats on each table.
179+
for _, table := range gen.Tables() {
180+
r.Exec(b, fmt.Sprintf("ANALYZE %q", table.Name))
181+
}
182+
170183
return tc, pgURLs
171184
}
172185

0 commit comments

Comments
 (0)