(cmd *cobra.Command, _ []string)
| 70 | } |
| 71 | |
| 72 | func mixedTxnFunc(cmd *cobra.Command, _ []string) { |
| 73 | if keySpaceSize <= 0 { |
| 74 | fmt.Fprintf(os.Stderr, "expected positive --key-space-size, got (%v)", keySpaceSize) |
| 75 | os.Exit(1) |
| 76 | } |
| 77 | |
| 78 | if rangeConsistency == "l" { |
| 79 | fmt.Println("bench with linearizable range") |
| 80 | } else if rangeConsistency == "s" { |
| 81 | fmt.Println("bench with serializable range") |
| 82 | } else { |
| 83 | fmt.Fprintln(os.Stderr, cmd.Usage()) |
| 84 | os.Exit(1) |
| 85 | } |
| 86 | |
| 87 | requests := make(chan request, totalClients) |
| 88 | if mixedTxnRate == 0 { |
| 89 | mixedTxnRate = math.MaxInt32 |
| 90 | } |
| 91 | limit := rate.NewLimiter(rate.Limit(mixedTxnRate), 1) |
| 92 | clients := mustCreateClients(totalClients, totalConns) |
| 93 | k, v := make([]byte, keySize), string(mustRandBytes(valSize)) |
| 94 | |
| 95 | bar = pb.New(mixedTxnTotal) |
| 96 | bar.Start() |
| 97 | |
| 98 | reportRead := newReport() |
| 99 | reportWrite := newReport() |
| 100 | for i := range clients { |
| 101 | wg.Add(1) |
| 102 | go func(c *v3.Client) { |
| 103 | defer wg.Done() |
| 104 | for req := range requests { |
| 105 | limit.Wait(context.Background()) |
| 106 | st := time.Now() |
| 107 | _, err := c.Txn(context.TODO()).Then(req.op).Commit() |
| 108 | if req.isWrite { |
| 109 | reportWrite.Results() <- report.Result{Err: err, Start: st, End: time.Now()} |
| 110 | } else { |
| 111 | reportRead.Results() <- report.Result{Err: err, Start: st, End: time.Now()} |
| 112 | } |
| 113 | bar.Increment() |
| 114 | } |
| 115 | }(clients[i]) |
| 116 | } |
| 117 | |
| 118 | go func() { |
| 119 | for i := 0; i < mixedTxnTotal; i++ { |
| 120 | var req request |
| 121 | if rand.Float64() < mixedTxnReadWriteRatio/(1+mixedTxnReadWriteRatio) { |
| 122 | opts := []v3.OpOption{v3.WithRange(mixedTxnEndKey)} |
| 123 | if rangeConsistency == "s" { |
| 124 | opts = append(opts, v3.WithSerializable()) |
| 125 | } |
| 126 | opts = append(opts, v3.WithPrefix(), v3.WithLimit(mixedTxnRangeLimit)) |
| 127 | req.op = v3.OpGet("", opts...) |
| 128 | req.isWrite = false |
| 129 | readOpsTotal++ |
nothing calls this directly
no test coverage detected
searching dependent graphs…