|
@@ -45,6 +45,7 @@ var (
|
|
|
stmKeyCount int
|
|
stmKeyCount int
|
|
|
stmValSize int
|
|
stmValSize int
|
|
|
stmWritePercent int
|
|
stmWritePercent int
|
|
|
|
|
+ stmMutex bool
|
|
|
mkSTM func(context.Context, *v3.Client, func(v3sync.STM) error) (*v3.TxnResponse, error)
|
|
mkSTM func(context.Context, *v3.Client, func(v3sync.STM) error) (*v3.TxnResponse, error)
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -56,6 +57,7 @@ func init() {
|
|
|
stmCmd.Flags().IntVar(&stmTotal, "total", 10000, "Total number of completed STM transactions")
|
|
stmCmd.Flags().IntVar(&stmTotal, "total", 10000, "Total number of completed STM transactions")
|
|
|
stmCmd.Flags().IntVar(&stmKeysPerTxn, "keys-per-txn", 1, "Number of keys to access per transaction")
|
|
stmCmd.Flags().IntVar(&stmKeysPerTxn, "keys-per-txn", 1, "Number of keys to access per transaction")
|
|
|
stmCmd.Flags().IntVar(&stmWritePercent, "txn-wr-percent", 50, "Percentage of keys to overwrite per transaction")
|
|
stmCmd.Flags().IntVar(&stmWritePercent, "txn-wr-percent", 50, "Percentage of keys to overwrite per transaction")
|
|
|
|
|
+ stmCmd.Flags().BoolVar(&stmMutex, "use-mutex", false, "Wrap STM transaction in a distributed mutex")
|
|
|
stmCmd.Flags().IntVar(&stmValSize, "val-size", 8, "Value size of each STM put request")
|
|
stmCmd.Flags().IntVar(&stmValSize, "val-size", 8, "Value size of each STM put request")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -139,9 +141,20 @@ func stmFunc(cmd *cobra.Command, args []string) {
|
|
|
func doSTM(ctx context.Context, client *v3.Client, requests <-chan stmApply) {
|
|
func doSTM(ctx context.Context, client *v3.Client, requests <-chan stmApply) {
|
|
|
defer wg.Done()
|
|
defer wg.Done()
|
|
|
|
|
|
|
|
|
|
+ var m *v3sync.Mutex
|
|
|
|
|
+ if stmMutex {
|
|
|
|
|
+ m = v3sync.NewMutex(client, "stmlock")
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
for applyf := range requests {
|
|
for applyf := range requests {
|
|
|
st := time.Now()
|
|
st := time.Now()
|
|
|
|
|
+ if m != nil {
|
|
|
|
|
+ m.Lock(context.TODO())
|
|
|
|
|
+ }
|
|
|
_, err := mkSTM(context.TODO(), client, applyf)
|
|
_, err := mkSTM(context.TODO(), client, applyf)
|
|
|
|
|
+ if m != nil {
|
|
|
|
|
+ m.Unlock(context.TODO())
|
|
|
|
|
+ }
|
|
|
var errStr string
|
|
var errStr string
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
errStr = err.Error()
|
|
errStr = err.Error()
|