Documentation ¶
Overview ¶
Package sync is an extension of the stdlib "sync" package. It has extra functionality that helps debug the use of synchronization primitives. The package should be importable in place of "sync". The extra functionality can be enabled by calling Enable() or passing a non-empty PPROF_SYNC environment variable to the process.
Several profiles are exposed on the default HTTP muxer (and to "/debug/pprof" when "net/http/pprof" is imported by the process). "lockHolders" lists the stack traces of goroutines that called Mutex.Lock that haven't subsequently been Unlocked. "lockBlockers" contains goroutines that are waiting to obtain locks. "/debug/lockTimes" or PrintLockTimes() shows the longest time a lock is held for each stack trace.
Note that currently RWMutex is treated like a Mutex when the package is enabled.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var OnceFunc = sync.OnceFunc
Functions ¶
func EnableContention ¶
func EnableContention()
func EnableLockTimes ¶
func EnableLockTimes()
func PrintLockTimes ¶
Writes out the longest time a Mutex remains locked for each stack trace that locks a Mutex.
Types ¶
type RWMutex ¶
type RWMutex struct {
// contains filtered or unexported fields
}
This RWMutex's RLock and RUnlock methods don't allow shared reading because there's no way to determine what goroutine has stopped holding the read lock when RUnlock is called. So for debugging purposes when the package is Enable()d, it's just like Mutex.