aboutsummaryrefslogtreecommitdiff
path: root/funcs.go
diff options
context:
space:
mode:
authorMatt Joiner <anacrolix@gmail.com>2019-11-05 11:47:44 +1100
committerMatt Joiner <anacrolix@gmail.com>2019-11-05 11:47:44 +1100
commit1d470e07f4c8f5609eb47ac0bfd675a22872a3d4 (patch)
treeb41cc7dde356edd839d13278600953d8490f42e7 /funcs.go
parentUpdate go.mod (diff)
downloadstm-1d470e07f4c8f5609eb47ac0bfd675a22872a3d4.tar.gz
stm-1d470e07f4c8f5609eb47ac0bfd675a22872a3d4.tar.xz
Add expvars
Diffstat (limited to 'funcs.go')
-rw-r--r--funcs.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/funcs.go b/funcs.go
index a311c9f..3d89cc5 100644
--- a/funcs.go
+++ b/funcs.go
@@ -6,6 +6,7 @@ import (
var (
txPool = sync.Pool{New: func() interface{} {
+ expvars.Add("new txs", 1)
tx := &Tx{
reads: make(map[*Var]uint64),
writes: make(map[*Var]interface{}),
@@ -17,6 +18,7 @@ var (
// Atomically executes the atomic function fn.
func Atomically(fn func(*Tx)) interface{} {
+ expvars.Add("atomically", 1)
// run the transaction
tx := txPool.Get().(*Tx)
retry:
@@ -29,8 +31,10 @@ retry:
return
}
if _ret, ok := r.(_return); ok {
+ expvars.Add("explicit returns", 1)
ret = _ret.value
} else if r == Retry {
+ expvars.Add("retries", 1)
// wait for one of the variables we read to change before retrying
tx.wait()
retry = true
@@ -47,11 +51,13 @@ retry:
tx.lockAllVars()
if !tx.verify() {
tx.unlock()
+ expvars.Add("failed commits", 1)
goto retry
}
// commit the write log and broadcast that variables have changed
tx.commit()
tx.unlock()
+ expvars.Add("commits", 1)
tx.recycle()
return ret
}