From 443c0b33d649e0f5e804ce126e371ec47a15805e Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 5 Nov 2019 18:55:37 +1100 Subject: Add failed commits profiling --- funcs.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'funcs.go') 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 -- cgit v1.2.3