aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/runtime/runtime1.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/runtime/runtime1.go')
-rw-r--r--libgo/go/runtime/runtime1.go29
1 files changed, 25 insertions, 4 deletions
diff --git a/libgo/go/runtime/runtime1.go b/libgo/go/runtime/runtime1.go
index 39969d1..143d19e 100644
--- a/libgo/go/runtime/runtime1.go
+++ b/libgo/go/runtime/runtime1.go
@@ -5,6 +5,7 @@
package runtime
import (
+ "internal/bytealg"
"runtime/internal/atomic"
"runtime/internal/sys"
"unsafe"
@@ -310,7 +311,6 @@ type dbgVar struct {
// existing int var for that value, which may
// already have an initial value.
var debug struct {
- allocfreetrace int32
cgocheck int32
clobberfree int32
efence int32
@@ -321,13 +321,20 @@ var debug struct {
gctrace int32
invalidptr int32
madvdontneed int32 // for Linux; issue 28466
- sbrk int32
scavenge int32
scavtrace int32
scheddetail int32
schedtrace int32
tracebackancestors int32
asyncpreemptoff int32
+
+ // debug.malloc is used as a combined debug check
+ // in the malloc function and should be set
+ // if any of the below debug options is != 0.
+ malloc bool
+ allocfreetrace int32
+ inittrace int32
+ sbrk int32
}
var dbgvars = []dbgVar{
@@ -349,6 +356,7 @@ var dbgvars = []dbgVar{
{"schedtrace", &debug.schedtrace},
{"tracebackancestors", &debug.tracebackancestors},
{"asyncpreemptoff", &debug.asyncpreemptoff},
+ {"inittrace", &debug.inittrace},
}
func parsedebugvars() {
@@ -361,16 +369,27 @@ func parsedebugvars() {
// ensure that we only trace allocated heap objects, which should
// not contain invalid pointers.
debug.invalidptr = 1
+ if GOOS == "linux" {
+ // On Linux, MADV_FREE is faster than MADV_DONTNEED,
+ // but doesn't affect many of the statistics that
+ // MADV_DONTNEED does until the memory is actually
+ // reclaimed. This generally leads to poor user
+ // experience, like confusing stats in top and other
+ // monitoring tools; and bad integration with
+ // management systems that respond to memory usage.
+ // Hence, default to MADV_DONTNEED.
+ debug.madvdontneed = 1
+ }
for p := gogetenv("GODEBUG"); p != ""; {
field := ""
- i := index(p, ",")
+ i := bytealg.IndexByteString(p, ',')
if i < 0 {
field, p = p, ""
} else {
field, p = p[:i], p[i+1:]
}
- i = index(field, "=")
+ i = bytealg.IndexByteString(field, '=')
if i < 0 {
continue
}
@@ -394,6 +413,8 @@ func parsedebugvars() {
}
}
+ debug.malloc = (debug.allocfreetrace | debug.inittrace | debug.sbrk) != 0
+
setTraceback(gogetenv("GOTRACEBACK"))
traceback_env = traceback_cache
}