libgo patch committed: Add memprofilerate as GODEBUG option
Ian Lance Taylor
iant@golang.org
Fri Feb 6 05:03:00 GMT 2015
This patch from Lynn Boger adds memprofilerate as an option for the
GODEBUG environment variable, to match the gc compiler. Bootstrapped
and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to
mainline.
Ian
-------------- next part --------------
diff -r 18b325ce33aa libgo/go/runtime/extern.go
--- a/libgo/go/runtime/extern.go Tue Feb 03 13:38:53 2015 -0800
+++ b/libgo/go/runtime/extern.go Thu Feb 05 21:01:15 2015 -0800
@@ -39,6 +39,10 @@
gcdead: setting gcdead=1 causes the garbage collector to clobber all stack slots
that it thinks are dead.
+ memprofilerate: setting memprofilerate=X changes the setting for
+ runtime.MemProfileRate. Refer to the description of this variable for how
+ it is used and its default value.
+
scheddetail: setting schedtrace=X and scheddetail=1 causes the scheduler to emit
detailed multiline info every X milliseconds, describing state of the scheduler,
processors, threads and goroutines.
diff -r 18b325ce33aa libgo/runtime/runtime.c
--- a/libgo/runtime/runtime.c Tue Feb 03 13:38:53 2015 -0800
+++ b/libgo/runtime/runtime.c Thu Feb 05 21:01:15 2015 -0800
@@ -22,6 +22,10 @@
// gotraceback value.
static uint32 traceback_cache = ~(uint32)0;
+extern volatile intgo runtime_MemProfileRate
+ __asm__ (GOSYM_PREFIX "runtime.MemProfileRate");
+
+
// The GOTRACEBACK environment variable controls the
// behavior of a Go program that is crashing and exiting.
// GOTRACEBACK=0 suppress all tracebacks
@@ -315,6 +319,11 @@
DebugVars runtime_debug;
+// Holds variables parsed from GODEBUG env var,
+// except for "memprofilerate" since there is an
+// existing var for that value which is int
+// instead of in32 and might have an
+// initial value.
static struct {
const char* name;
int32* value;
@@ -349,7 +358,12 @@
for(;;) {
for(i=0; i<(intgo)nelem(dbgvar); i++) {
n = runtime_findnull((const byte*)dbgvar[i].name);
- if(runtime_mcmp(p, dbgvar[i].name, n) == 0 && p[n] == '=')
+ if(runtime_mcmp(p, "memprofilerate", n) == 0 && p[n] == '=')
+ // Set the MemProfileRate directly since it
+ // is an int, not int32, and should only lbe
+ // set here if specified by GODEBUG
+ runtime_MemProfileRate = runtime_atoi(p+n+1);
+ else if(runtime_mcmp(p, dbgvar[i].name, n) == 0 && p[n] == '=')
*dbgvar[i].value = runtime_atoi(p+n+1);
}
p = (const byte *)runtime_strstr((const char *)p, ",");
More information about the Gcc-patches
mailing list