Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add an option to enable the runtime mutex profiling #4031

Merged
merged 1 commit into from
Jun 21, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions go/vt/servenv/servenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ var (
Port *int

// Flags to alter the behavior of the library.
lameduckPeriod = flag.Duration("lameduck-period", 50*time.Millisecond, "keep running at least this long after SIGTERM before stopping")
onTermTimeout = flag.Duration("onterm_timeout", 10*time.Second, "wait no more than this for OnTermSync handlers before stopping")
memProfileRate = flag.Int("mem-profile-rate", 512*1024, "profile every n bytes allocated")
lameduckPeriod = flag.Duration("lameduck-period", 50*time.Millisecond, "keep running at least this long after SIGTERM before stopping")
onTermTimeout = flag.Duration("onterm_timeout", 10*time.Second, "wait no more than this for OnTermSync handlers before stopping")
memProfileRate = flag.Int("mem-profile-rate", 512*1024, "profile every n bytes allocated")
mutexProfileFraction = flag.Int("mutex-profile-fraction", 0, "profile every n mutex contention events (see runtime.SetMutexProfileFraction)")

// mutex used to protect the Init function
mu sync.Mutex
Expand Down Expand Up @@ -89,6 +90,11 @@ func Init() {

runtime.MemProfileRate = *memProfileRate

if *mutexProfileFraction != 0 {
log.Infof("setting mutex profile fraction to %v", *mutexProfileFraction)
runtime.SetMutexProfileFraction(*mutexProfileFraction)
}

// We used to set this limit directly, but you pretty much have to
// use a root account to allow increasing a limit reliably. Dropping
// privileges is also tricky. The best strategy is to make a shell
Expand Down