Set runtime.MemProfileRate for the compilation to rate.
-msan
Insert calls to C/C++ memory sanitizer.
+ -mutexprofile file
+ Write mutex profile for the compilation to file.
-nolocalimports
Disallow local (relative) imports.
-o file
--- /dev/null
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !go1.8
+
+package gc
+
+import "runtime"
+
+func startMutexProfiling() {
+ Fatalf("mutex profiling unavailable in version %v", runtime.Version())
+}
flag.Int64Var(&memprofilerate, "memprofilerate", 0, "set runtime.MemProfileRate to `rate`")
flag.StringVar(&traceprofile, "traceprofile", "", "write an execution trace to `file`")
flag.StringVar(&blockprofile, "blockprofile", "", "write block profile to `file`")
+ flag.StringVar(&mutexprofile, "mutexprofile", "", "write mutex profile to `file`")
flag.StringVar(&benchfile, "bench", "", "append benchmark times to `file`")
obj.Flagparse(usage)
--- /dev/null
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build go1.8
+
+package gc
+
+import "runtime"
+
+func startMutexProfiling() {
+ runtime.SetMutexProfileFraction(1)
+}
memprofilerate int64
traceprofile string
traceHandler func(string)
+ mutexprofile string
)
func startProfile() {
f.Close()
})
}
+ if mutexprofile != "" {
+ f, err := os.Create(mutexprofile)
+ if err != nil {
+ Fatalf("%v", err)
+ }
+ startMutexProfiling()
+ atExit(func() {
+ pprof.Lookup("mutex").WriteTo(f, 0)
+ f.Close()
+ })
+ }
if traceprofile != "" && traceHandler != nil {
traceHandler(traceprofile)
}