From 877bf18b7e26a4ee958fa4839c185c87fbcd7560 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Fri, 2 Oct 2020 17:33:20 +1000 Subject: Add retry profiling --- retry.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'retry.go') diff --git a/retry.go b/retry.go index 92efb9e..1997b18 100644 --- a/retry.go +++ b/retry.go @@ -1,14 +1,20 @@ package stm -// Retry is a sentinel value. When thrown via panic, it indicates that a +import ( + "runtime/pprof" +) + +var retries = pprof.NewProfile("stmRetries") + +// retry is a sentinel value. When thrown via panic, it indicates that a // transaction should be retried. -const Retry = "retry" +var retry = &struct{}{} // catchRetry returns true if fn calls tx.Retry. -func catchRetry(fn Operation, tx *Tx) (result interface{}, retry bool) { +func catchRetry(fn Operation, tx *Tx) (result interface{}, gotRetry bool) { defer func() { - if r := recover(); r == Retry { - retry = true + if r := recover(); r == retry { + gotRetry = true } else if r != nil { panic(r) } -- cgit v1.2.3