github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/cmd/roachtest/ycsb.go (about) 1 // Copyright 2018 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package main 12 13 import ( 14 "context" 15 "fmt" 16 ) 17 18 func registerYCSB(r *testRegistry) { 19 workloads := []string{"A", "B", "C", "D", "E", "F"} 20 cpusConfigs := []int{8, 32} 21 22 // concurrencyConfigs contains near-optimal concurrency levels for each 23 // (workload, cpu count) combination. All of these figures were tuned on GCP 24 // n1-standard instance types. We should consider implementing a search for 25 // the optimal concurrency level in the roachtest itself (see kvbench). 26 concurrencyConfigs := map[string] /* workload */ map[int] /* cpus */ int{ 27 "A": {8: 96, 32: 144}, 28 "B": {8: 144, 32: 192}, 29 "C": {8: 144, 32: 192}, 30 "D": {8: 96, 32: 144}, 31 "E": {8: 96, 32: 144}, 32 "F": {8: 96, 32: 144}, 33 } 34 35 runYCSB := func(ctx context.Context, t *test, c *cluster, wl string, cpus int) { 36 nodes := c.spec.NodeCount - 1 37 38 conc, ok := concurrencyConfigs[wl][cpus] 39 if !ok { 40 t.Fatalf("missing concurrency for (workload, cpus) = (%s, %d)", wl, cpus) 41 } 42 43 c.Put(ctx, cockroach, "./cockroach", c.Range(1, nodes)) 44 c.Put(ctx, workload, "./workload", c.Node(nodes+1)) 45 c.Start(ctx, t, c.Range(1, nodes)) 46 waitForFullReplication(t, c.Conn(ctx, 1)) 47 48 t.Status("running workload") 49 m := newMonitor(ctx, c, c.Range(1, nodes)) 50 m.Go(func(ctx context.Context) error { 51 sfu := fmt.Sprintf(" --select-for-update=%t", t.IsBuildVersion("v19.2.0")) 52 ramp := " --ramp=" + ifLocal("0s", "1m") 53 duration := " --duration=" + ifLocal("10s", "10m") 54 cmd := fmt.Sprintf( 55 "./workload run ycsb --init --insert-count=1000000 --workload=%s --concurrency=%d"+ 56 " --splits=%d --histograms="+perfArtifactsDir+"/stats.json"+sfu+ramp+duration+ 57 " {pgurl:1-%d}", 58 wl, conc, nodes, nodes) 59 c.Run(ctx, c.Node(nodes+1), cmd) 60 return nil 61 }) 62 m.Wait() 63 } 64 65 for _, wl := range workloads { 66 for _, cpus := range cpusConfigs { 67 var name string 68 if cpus == 8 { // support legacy test name which didn't include cpu 69 name = fmt.Sprintf("ycsb/%s/nodes=3", wl) 70 } else { 71 name = fmt.Sprintf("ycsb/%s/nodes=3/cpu=%d", wl, cpus) 72 } 73 wl, cpus := wl, cpus 74 r.Add(testSpec{ 75 Name: name, 76 Owner: OwnerKV, 77 Cluster: makeClusterSpec(4, cpu(cpus)), 78 Run: func(ctx context.Context, t *test, c *cluster) { 79 runYCSB(ctx, t, c, wl, cpus) 80 }, 81 }) 82 } 83 } 84 }