-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
tpcc.go
786 lines (705 loc) · 22.6 KB
/
tpcc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
// Copyright 2018 The Cockroach Authors.
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License. See the AUTHORS file
// for names of contributors.
package main
import (
"bytes"
"context"
"fmt"
"math"
"math/rand"
"strconv"
"strings"
"time"
"github.com/lib/pq"
"github.com/pkg/errors"
"golang.org/x/sync/errgroup"
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror"
"github.com/cockroachdb/cockroach/pkg/util/search"
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
"github.com/cockroachdb/ttycolor"
)
type tpccOptions struct {
Warehouses int
Extra string
Chaos func() Chaos // for late binding of stopper
During func(context.Context) error // for running a function during the test
Duration time.Duration
ZFS bool
}
func runTPCC(ctx context.Context, t *test, c *cluster, opts tpccOptions) {
crdbNodes := c.Range(1, c.nodes-1)
workloadNode := c.Node(c.nodes)
rampDuration := 5 * time.Minute
if c.isLocal() {
opts.Warehouses = 1
opts.Duration = 1 * time.Minute
rampDuration = 30 * time.Second
} else if !opts.ZFS {
c.RemountNoBarrier(ctx)
}
c.Put(ctx, cockroach, "./cockroach", crdbNodes)
c.Put(ctx, workload, "./workload", workloadNode)
t.Status("loading fixture")
fixtureWarehouses := -1
for _, w := range []int{1, 10, 100, 1000, 2000, 5000, 10000} {
if w >= opts.Warehouses {
fixtureWarehouses = w
break
}
}
if fixtureWarehouses == -1 {
t.Fatalf("could not find fixture big enough for %d warehouses", opts.Warehouses)
}
func() {
db := c.Conn(ctx, 1)
defer db.Close()
if opts.ZFS {
if err := c.RunE(ctx, c.Node(1), "test -d /mnt/data1/.zfs/snapshot/pristine"); err != nil {
// Use ZFS so the initial store dumps can be instantly rolled back to their
// pristine state. Useful for iterating quickly on the test, especially when
// used in a repro.
c.Reformat(ctx, crdbNodes, "zfs")
t.Status("loading dataset")
c.Start(ctx, t, crdbNodes)
cmd := fmt.Sprintf(
"./workload fixtures load tpcc --warehouses=%d {pgurl:1}", fixtureWarehouses)
c.Run(ctx, workloadNode, cmd)
c.Stop(ctx, crdbNodes)
c.Run(ctx, crdbNodes, "test -e /sbin/zfs && sudo zfs snapshot data1@pristine")
}
t.Status(`restoring store dumps`)
c.Run(ctx, crdbNodes, "sudo zfs rollback data1@pristine")
c.Start(ctx, t, crdbNodes)
} else {
c.Start(ctx, t, crdbNodes)
c.Run(ctx, workloadNode, fmt.Sprintf(
`./workload fixtures load tpcc --warehouses=%d {pgurl:1}`, fixtureWarehouses,
))
}
}()
t.Status("waiting")
m := newMonitor(ctx, c, crdbNodes)
m.Go(func(ctx context.Context) error {
t.WorkerStatus("running tpcc")
cmd := fmt.Sprintf(
"./workload run tpcc --warehouses=%d --histograms=logs/stats.json "+
opts.Extra+" --ramp=%s --duration=%s {pgurl:1-%d}",
opts.Warehouses, rampDuration, opts.Duration, c.nodes-1)
c.Run(ctx, workloadNode, cmd)
return nil
})
if opts.Chaos != nil {
chaos := opts.Chaos()
m.Go(chaos.Runner(c, m))
}
if opts.During != nil {
m.Go(opts.During)
}
m.Wait()
c.Run(ctx, workloadNode, fmt.Sprintf(
"./workload check tpcc --warehouses=%d {pgurl:1}", opts.Warehouses))
}
func registerTPCC(r *registry) {
r.Add(testSpec{
Name: "tpcc/nodes=3/w=max",
// TODO(dan): Instead of MinVersion, adjust the warehouses below to
// match our expectation for the max tpcc warehouses that previous
// releases will support on this hardware.
MinVersion: "2.1.0",
Nodes: nodes(4, cpu(16)),
Stable: false,
Run: func(ctx context.Context, t *test, c *cluster) {
warehouses := 1400
runTPCC(ctx, t, c, tpccOptions{
Warehouses: warehouses, Duration: 120 * time.Minute,
})
},
})
r.Add(testSpec{
Name: "tpcc-nowait/nodes=3/w=1",
Nodes: nodes(4, cpu(16)),
Stable: false,
Run: func(ctx context.Context, t *test, c *cluster) {
runTPCC(ctx, t, c, tpccOptions{
Warehouses: 1,
Duration: 10 * time.Minute,
Extra: "--wait=false",
})
},
})
r.Add(testSpec{
Name: "tpcc/w=100/nodes=3/chaos=true",
Nodes: nodes(4),
Stable: false,
Run: func(ctx context.Context, t *test, c *cluster) {
duration := 30 * time.Minute
runTPCC(ctx, t, c, tpccOptions{
Warehouses: 100,
Duration: duration,
Extra: "--wait=false --tolerate-errors",
Chaos: func() Chaos {
return Chaos{
Timer: Periodic{
Period: 45 * time.Second,
DownTime: 10 * time.Second,
},
Target: func() nodeListOption { return c.Node(1 + rand.Intn(c.nodes-1)) },
Stopper: time.After(duration),
DrainAndQuit: false,
}
},
ZFS: false, // change to true during debugging/development
})
},
})
// Run a few representative tpccbench specs in CI.
registerTPCCBenchSpec(r, tpccBenchSpec{
Nodes: 3,
CPUs: 4,
LoadWarehouses: 1000,
EstimatedMax: 300,
})
registerTPCCBenchSpec(r, tpccBenchSpec{
Nodes: 9,
CPUs: 4,
Chaos: true,
LoadConfig: singlePartitionedLoadgen,
LoadWarehouses: 2000,
EstimatedMax: 600,
})
}
// tpccBenchDistribution represents a distribution of nodes in a tpccbench
// cluster.
type tpccBenchDistribution int
const (
// All nodes are within the same zone.
singleZone tpccBenchDistribution = iota
// Nodes are distributed across 3 zones, all in the same region.
multiZone
// Nodes are distributed across 3 regions.
multiRegion
)
func (d tpccBenchDistribution) zones() []string {
switch d {
case singleZone:
return []string{"us-central1-b"}
case multiZone:
return []string{"us-central1-a", "us-central1-b", "us-central1-c"}
case multiRegion:
return []string{"us-east1-b", "us-west1-b", "europe-west2-b"}
default:
panic("unexpected")
}
}
// tpccBenchLoadConfig represents configurations of load generators in a
// tpccbench spec.
type tpccBenchLoadConfig int
const (
// A single load generator is run.
singleLoadgen tpccBenchLoadConfig = iota
// A single load generator is run with partitioning enabled.
singlePartitionedLoadgen
// A load generator is run in each zone.
multiLoadgen
)
// numLoadNodes returns the number of load generator nodes that the load
// configuration requires for the given node distribution.
func (l tpccBenchLoadConfig) numLoadNodes(d tpccBenchDistribution) int {
switch l {
case singleLoadgen:
return 1
case singlePartitionedLoadgen:
return 1
case multiLoadgen:
return len(d.zones())
default:
panic("unexpected")
}
}
type tpccBenchSpec struct {
Nodes int
CPUs int
Chaos bool
Distribution tpccBenchDistribution
LoadConfig tpccBenchLoadConfig
// The number of warehouses to load into the cluster before beginning
// benchmarking. Should be larger than EstimatedMax and should be a
// value that is unlikely to be achievable.
LoadWarehouses int
// An estimate of the maximum number of warehouses achievable in the
// cluster config. The closer this is to the actual max achievable
// warehouse count, the faster the benchmark will be in producing a
// result. This can be adjusted over time as performance characteristics
// change (i.e. CockroachDB gets faster!).
EstimatedMax int
// An optional version that is part of a URL pointing at a pre-generated
// store dump directory. Can be used to speed up dataset loading on fresh
// clusters.
StoreDirVersion string
}
// partitions returns the number of partitions specified to the load generator.
func (s tpccBenchSpec) partitions() int {
switch s.LoadConfig {
case singleLoadgen:
return 0
case singlePartitionedLoadgen:
return s.Nodes / 3
case multiLoadgen:
return len(s.Distribution.zones())
default:
panic("unexpected")
}
}
// startOpts returns any extra start options that the spec requires.
func (s tpccBenchSpec) startOpts() []option {
var opts []option
if s.LoadConfig == singlePartitionedLoadgen {
opts = append(opts, racks(s.partitions()))
}
return opts
}
func registerTPCCBenchSpec(r *registry, b tpccBenchSpec) {
nameParts := []string{
"tpccbench",
fmt.Sprintf("nodes=%d", b.Nodes),
fmt.Sprintf("cpu=%d", b.CPUs),
}
if b.Chaos {
nameParts = append(nameParts, "chaos")
}
opts := []createOption{cpu(b.CPUs)}
switch b.Distribution {
case singleZone:
// No specifier.
case multiZone:
nameParts = append(nameParts, "multi-az")
opts = append(opts, geo(), zones(strings.Join(b.Distribution.zones(), ",")))
case multiRegion:
nameParts = append(nameParts, "multi-region")
opts = append(opts, geo(), zones(strings.Join(b.Distribution.zones(), ",")))
default:
panic("unexpected")
}
switch b.LoadConfig {
case singleLoadgen:
// No specifier.
case singlePartitionedLoadgen:
nameParts = append(nameParts, "partition")
case multiLoadgen:
// No specifier.
default:
panic("unexpected")
}
name := strings.Join(nameParts, "/")
numNodes := b.Nodes + b.LoadConfig.numLoadNodes(b.Distribution)
nodes := nodes(numNodes, opts...)
r.Add(testSpec{
Name: name,
Nodes: nodes,
Stable: true, // DO NOT COPY to new tests
Run: func(ctx context.Context, t *test, c *cluster) {
runTPCCBench(ctx, t, c, b)
},
})
}
// loadTPCCBench loads a TPCC dataset for the specific benchmark spec. The
// function is idempotent and first checks whether a compatible dataset exists,
// performing an expensive dataset restore only if it doesn't.
func loadTPCCBench(
ctx context.Context, t *test, c *cluster, b tpccBenchSpec, roachNodes, loadNode nodeListOption,
) error {
db := c.Conn(ctx, 1)
defer db.Close()
if _, err := db.ExecContext(ctx, `SET CLUSTER SETTING kv.range_merge.queue_enabled = false`); err != nil {
return err
}
// Check if the dataset already exists and is already large enough to
// accommodate this benchmarking. If so, we can skip the fixture RESTORE.
if _, err := db.ExecContext(ctx, `USE tpcc`); err == nil {
t.l.Printf("found existing tpcc database\n")
var curWarehouses int
if err := db.QueryRowContext(ctx,
`SELECT count(*) FROM tpcc.warehouse`,
).Scan(&curWarehouses); err != nil {
return err
}
if curWarehouses >= b.LoadWarehouses {
// The cluster has enough warehouses. Nothing to do.
return nil
}
// If the dataset exists but is not large enough, wipe the cluster
// before restoring.
c.Wipe(ctx, roachNodes)
c.Start(ctx, t, append(b.startOpts(), roachNodes)...)
} else if pqErr, ok := err.(*pq.Error); !ok ||
string(pqErr.Code) != pgerror.CodeInvalidCatalogNameError {
return err
}
// If the fixture has a corresponding store dump, use it.
if b.StoreDirVersion != "" {
t.l.Printf("ingesting existing tpcc store dump\n")
urlBase, err := c.RunWithBuffer(ctx, t.l, c.Node(loadNode[0]),
fmt.Sprintf(`./workload fixtures url tpcc --warehouses=%d`, b.LoadWarehouses))
if err != nil {
return err
}
fixtureURL := string(bytes.TrimSpace(urlBase))
storeDirsPath := storeDirURL(fixtureURL, len(roachNodes), b.StoreDirVersion)
return downloadStoreDumps(ctx, c, storeDirsPath, len(roachNodes))
}
// Load the corresponding fixture.
t.l.Printf("restoring tpcc fixture\n")
cmd := fmt.Sprintf(
"./workload fixtures load tpcc --checks=false --warehouses=%d {pgurl:1}", b.LoadWarehouses)
if err := c.RunE(ctx, loadNode, cmd); err != nil {
return err
}
partArgs := ""
rebalanceWait := time.Duration(b.LoadWarehouses/100) * time.Minute
switch b.LoadConfig {
case singleLoadgen:
t.l.Printf("splitting and scattering\n")
case singlePartitionedLoadgen:
t.l.Printf("splitting, scattering, and partitioning\n")
partArgs = fmt.Sprintf(`--partitions=%d`, b.partitions())
rebalanceWait = time.Duration(b.LoadWarehouses/50) * time.Minute
case multiLoadgen:
t.l.Printf("splitting, scattering, and partitioning\n")
partArgs = fmt.Sprintf(`--partitions=%d --zones="%s" --partition-affinity=0`,
b.partitions(), strings.Join(b.Distribution.zones(), ","))
rebalanceWait = time.Duration(b.LoadWarehouses/20) * time.Minute
default:
panic("unexpected")
}
t.l.Printf("waiting %v for rebalancing\n", rebalanceWait)
_, err := db.ExecContext(ctx, `SET CLUSTER SETTING kv.snapshot_rebalance.max_rate='64MiB'`)
if err != nil {
return err
}
// Split and scatter the tables. Ramp up to the expected load in the desired
// distribution. This should allow for load-based rebalancing to help
// distribute load. Optionally pass some load configuration-specific flags.
cmd = fmt.Sprintf("./workload run tpcc --warehouses=%d --split --scatter "+
"--ramp=%s --duration=1ms --tolerate-errors %s {pgurl%s}",
b.LoadWarehouses, rebalanceWait, partArgs, roachNodes)
if out, err := c.RunWithBuffer(ctx, c.l, loadNode, cmd); err != nil {
return errors.Wrapf(err, "failed with output %q", string(out))
}
_, err = db.ExecContext(ctx, `SET CLUSTER SETTING kv.snapshot_rebalance.max_rate='2MiB'`)
return err
}
// tpccbench is a suite of benchmarking tools that run TPC-C against CockroachDB
// clusters in different configurations. The tools search for the maximum number
// of warehouses that a load generator can run TPC-C against while still
// maintaining a minimum acceptable throughput. This maximum warehouse value is
// directly comparable to other runs of the tool in the same cluster config, and
// expresses how well CockroachDB performance scales.
//
// In order to run a benchmark spec, the tool must first load a TPC-C dataset
// large enough to accommodate it. This can take a while, so it is recommended
// to use a combination of `--cluster=<cluster>` and `--wipe=false` flags to
// limit the loading phase to the first run of the tool. Subsequent runs will be
// able to avoid the dataset restore as long as they are not wiped. This allows
// for quick iteration on experimental changes.
//
// It can also be useful to omit the `--cluster` flag during the first run of
// the tool to allow roachtest to create the correct set of VMs required by the
// test. The `--wipe` flag will prevent this cluster from being destroyed, so it
// can then be used during future runs.
func runTPCCBench(ctx context.Context, t *test, c *cluster, b tpccBenchSpec) {
// Determine the nodes in each load group. A load group consists of a set of
// Cockroach nodes and a single load generator.
numLoadGroups := b.LoadConfig.numLoadNodes(b.Distribution)
nodesPerGroup := c.nodes / numLoadGroups
loadGroup := make([]struct{ roachNodes, loadNodes nodeListOption }, numLoadGroups)
for i, j := 1, 0; i <= c.nodes; i += nodesPerGroup {
loadGroup[j].roachNodes = c.Range(i, i+nodesPerGroup-2)
loadGroup[j].loadNodes = c.Node(i + nodesPerGroup - 1)
j++
}
// Aggregate nodes across load groups.
var roachNodes nodeListOption
var loadNodes nodeListOption
for _, g := range loadGroup {
roachNodes = roachNodes.merge(g.roachNodes)
loadNodes = loadNodes.merge(g.loadNodes)
}
// Disable write barrier on mounted SSDs.
if !c.isLocal() {
c.RemountNoBarrier(ctx)
}
c.Put(ctx, cockroach, "./cockroach", roachNodes)
c.Put(ctx, workload, "./workload", loadNodes)
c.Start(ctx, t, append(b.startOpts(), roachNodes)...)
useHAProxy := b.Chaos
if useHAProxy {
if len(loadNodes) > 1 {
t.Fatal("distributed chaos benchmarking not supported")
}
t.Status("installing haproxy")
c.Install(ctx, loadNodes, "haproxy")
c.Put(ctx, cockroach, "./cockroach", loadNodes)
c.Run(ctx, loadNodes, fmt.Sprintf("./cockroach gen haproxy --insecure --host %s",
c.InternalIP(ctx, c.Node(1))[0]))
c.Run(ctx, loadNodes, "haproxy -f haproxy.cfg -D")
}
m := newMonitor(ctx, c, roachNodes)
m.Go(func(ctx context.Context) error {
t.Status("setting up dataset")
err := loadTPCCBench(ctx, t, c, b, roachNodes, c.Node(loadNodes[0]))
if err != nil {
return err
}
// Search between 1 and b.LoadWarehouses for the largest number of
// warehouses that can be operated on while sustaining a throughput
// threshold, set to a fraction of max tpmC.
precision := int(math.Max(1.0, float64(b.LoadWarehouses/200)))
initStepSize := precision
s := search.NewLineSearcher(1, b.LoadWarehouses, b.EstimatedMax, initStepSize, precision)
res, err := s.Search(func(warehouses int) (bool, error) {
// Restart the cluster before each iteration to help eliminate
// inter-trial interactions.
m.ExpectDeaths(int32(len(roachNodes)))
c.Stop(ctx, roachNodes)
c.Start(ctx, t, append(b.startOpts(), roachNodes)...)
time.Sleep(10 * time.Second)
// Set up the load generation configuration.
rampDur := 5 * time.Minute
loadDur := 10 * time.Minute
loadDone := make(chan time.Time, numLoadGroups)
// If we're running chaos in this configuration, modify this config.
if b.Chaos {
// Increase the load generation duration.
loadDur = 10 * time.Minute
// Kill one node at a time.
ch := Chaos{
Timer: Periodic{Period: 90 * time.Second, DownTime: 5 * time.Second},
Target: roachNodes.randNode,
Stopper: loadDone,
}
m.Go(ch.Runner(c, m))
}
if b.Distribution == multiRegion {
rampDur = 3 * time.Minute
loadDur = 15 * time.Minute
}
// If we're running multiple load generators, run them in parallel and then
// aggregate tpmCChan.
var eg errgroup.Group
tpmCChan := make(chan float64, len(loadGroup))
for groupIdx, group := range loadGroup {
// Copy for goroutine
groupIdx := groupIdx
group := group
eg.Go(func() error {
sqlGateways := group.roachNodes
if useHAProxy {
sqlGateways = group.loadNodes
}
extraFlags := ""
activeWarehouses := warehouses
switch b.LoadConfig {
case singleLoadgen:
// Nothing.
case singlePartitionedLoadgen:
extraFlags = fmt.Sprintf(` --partitions=%d --split`, b.partitions())
case multiLoadgen:
extraFlags = fmt.Sprintf(" --partitions=%d --partition-affinity=%d --split",
b.partitions(), groupIdx)
activeWarehouses = warehouses / numLoadGroups
default:
panic("unexpected")
}
t.Status(fmt.Sprintf("running benchmark, warehouses=%d", warehouses))
cmd := fmt.Sprintf("./workload run tpcc --warehouses=%d --active-warehouses=%d "+
"--tolerate-errors --ramp=%s --duration=%s%s {pgurl%s}",
b.LoadWarehouses, activeWarehouses, rampDur,
loadDur, extraFlags, sqlGateways)
out, err := c.RunWithBuffer(ctx, t.l, group.loadNodes, cmd)
loadDone <- timeutil.Now()
if err != nil {
return errors.Wrapf(err, "error running tpcc load generator:\n\n%s\n", out)
}
// Parse the stats header and stats lines from the output.
str := string(out)
lines := strings.Split(str, "\n")
for i, line := range lines {
if strings.Contains(line, "tpmC") {
lines = lines[i:]
}
if i == len(lines)-1 {
return errors.Errorf("tpmC not found in output:\n\n%s\n", out)
}
}
headerLine, statsLine := lines[0], lines[1]
t.l.Printf("%s\n%s\n", headerLine, statsLine)
// Parse tpmC value from stats line.
fields := strings.Fields(statsLine)
tpmC, err := strconv.ParseFloat(fields[1], 64)
if err != nil {
return err
}
tpmCChan <- tpmC
return nil
})
}
if err = eg.Wait(); err != nil {
return false, err
}
close(tpmCChan)
var tpmC float64
for partialTpMc := range tpmCChan {
tpmC += partialTpMc
}
// Determine the fraction of the maximum possible tpmC realized.
//
// The 12.605 is computed from the operation mix and the number of secs
// it takes to cycle through a deck:
//
// 10*(18+12) + 10*(3+12) + 1*(2+10) + 1*(2+5) + 1*(2+5) = 476
//
// 10 workers per warehouse times 10 newOrder ops per deck results in:
//
// (10*10)/(476/60) = 12.605...
maxTpmC := 12.605 * float64(warehouses)
tpmCRatio := tpmC / maxTpmC
// Determine whether this means the test passed or not. We use a
// threshold of 85% of max tpmC as the "passing" criteria for a
// given number of warehouses. This does not take response latencies
// for different op types into account directly as required by the
// formal TPC-C spec, but in practice it results in stable results.
passRatio := 0.85
pass := tpmCRatio > passRatio
// Print the result.
ttycolor.Stdout(ttycolor.Green)
passStr := "PASS"
if !pass {
ttycolor.Stdout(ttycolor.Red)
passStr = "FAIL"
}
t.l.Printf("--- %s: tpcc %d resulted in %.1f tpmC (%.1f%% of max tpmC)\n\n",
passStr, warehouses, tpmC, tpmCRatio*100)
ttycolor.Stdout(ttycolor.Reset)
return pass, nil
})
if err != nil {
return err
}
ttycolor.Stdout(ttycolor.Green)
t.l.Printf("------\nMAX WAREHOUSES = %d\n------\n\n", res)
ttycolor.Stdout(ttycolor.Reset)
return nil
})
m.Wait()
c.Stop(ctx, c.All())
}
func registerTPCCBench(r *registry) {
specs := []tpccBenchSpec{
{
Nodes: 3,
CPUs: 4,
LoadWarehouses: 1000,
EstimatedMax: 325,
// TODO(nvanbenschoten): Need to regenerate.
// StoreDirVersion: "2.0-5",
},
{
Nodes: 3,
CPUs: 16,
LoadWarehouses: 2000,
EstimatedMax: 1300,
},
{
Nodes: 9,
CPUs: 64,
LoadWarehouses: 10000,
EstimatedMax: 8000,
},
// objective 1, key result 1.
{
Nodes: 30,
CPUs: 16,
LoadWarehouses: 10000,
EstimatedMax: 5300,
},
// objective 1, key result 2.
{
Nodes: 18,
CPUs: 16,
LoadConfig: singlePartitionedLoadgen,
LoadWarehouses: 10000,
EstimatedMax: 8000,
},
// objective 2, key result 1.
{
Nodes: 7,
CPUs: 16,
Chaos: true,
LoadWarehouses: 5000,
EstimatedMax: 2000,
// TODO(nvanbenschoten): Need to regenerate.
// StoreDirVersion: "2.0-5",
},
// objective 3, key result 1.
{
Nodes: 3,
CPUs: 16,
Distribution: multiZone,
LoadWarehouses: 2000,
EstimatedMax: 1000,
},
// objective 3, key result 2.
{
Nodes: 9,
CPUs: 16,
Distribution: multiRegion,
LoadConfig: multiLoadgen,
LoadWarehouses: 5000,
EstimatedMax: 2200,
},
// objective 4, key result 2.
{
Nodes: 64,
CPUs: 16,
LoadWarehouses: 50000,
EstimatedMax: 40000,
},
// See https://github.com/cockroachdb/cockroach/issues/31409 for the next three specs.
{
Nodes: 6,
CPUs: 16,
LoadWarehouses: 5000,
EstimatedMax: 3000,
LoadConfig: singlePartitionedLoadgen,
},
{
Nodes: 12,
CPUs: 16,
LoadWarehouses: 10000,
EstimatedMax: 6000,
LoadConfig: singlePartitionedLoadgen,
},
{
Nodes: 24,
CPUs: 16,
LoadWarehouses: 20000,
EstimatedMax: 12000,
LoadConfig: singlePartitionedLoadgen,
},
}
for _, b := range specs {
registerTPCCBenchSpec(r, b)
}
}