aboutsummaryrefslogtreecommitdiff
path: root/funcs.go
diff options
context:
space:
mode:
Diffstat (limited to 'funcs.go')
-rw-r--r--funcs.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/funcs.go b/funcs.go
index bd7f0e9..cbd3590 100644
--- a/funcs.go
+++ b/funcs.go
@@ -1,6 +1,7 @@
package stm
import (
+ "runtime/pprof"
"sync"
)
@@ -14,8 +15,17 @@ var (
tx.cond.L = &tx.mu
return tx
}}
+ failedCommitsProfile *pprof.Profile
)
+const profileFailedCommits = false
+
+func init() {
+ if profileFailedCommits {
+ failedCommitsProfile = pprof.NewProfile("stmFailedCommits")
+ }
+}
+
// Atomically executes the atomic function fn.
func Atomically(fn func(*Tx)) interface{} {
expvars.Add("atomically", 1)
@@ -52,6 +62,9 @@ retry:
if !tx.verify() {
tx.unlock()
expvars.Add("failed commits", 1)
+ if profileFailedCommits {
+ failedCommitsProfile.Add(new(int), 0)
+ }
goto retry
}
// commit the write log and broadcast that variables have changed