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

proposal: runtime: Allow GODEBUG flags to be enabled dynamically #28623

Open
prashantv opened this Issue Nov 6, 2018 · 1 comment

Comments

Projects
None yet
3 participants
@prashantv
Contributor

prashantv commented Nov 6, 2018

Currently, runtime.parsedebugvars is called from schedinit which is part of binary bootstrap. This means it's not possible to dynamically enable GODEBUG features once a binary has started.

Typically, we don't want gc traces to flood our logs, but when debugging specific memory issues, it would be helpful if we could enable features (such as gctrace=1 and scavenge=1) dynamically.

While it doesn't have to be via os.Setenv, it;d be useful to have some way to dynamically enable GODEBUG features.

What version of Go are you using (go version)?

$ go version
go version go1.11.2 linux/amd64

Does this issue reproduce with the latest release?

Yes, I'm using the latest release.

What operating system and processor architecture are you using (go env)?

$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/prashant/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/prashant/go"
GOPROXY=""
GORACE=""
GOROOT="/home/prashant/bin/go1.11.2"
GOTMPDIR=""
GOTOOLDIR="/home/prashant/bin/go1.11.2/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build849457703=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Set GODEBUG to gctrace=1,scavenge=1 dynamically using os.Setenv.

What did you expect to see?

Expected to see GC traces once the variable was set.

What did you see instead?

No GC traces.

@agnivade agnivade changed the title from runtime: Allow GODEBUG flags to be enabled dynamically to proposal: runtime: Allow GODEBUG flags to be enabled dynamically Nov 7, 2018

@gopherbot gopherbot added this to the Proposal milestone Nov 7, 2018

@gopherbot gopherbot added the Proposal label Nov 7, 2018

@rsc

This comment has been minimized.

Contributor

rsc commented Nov 28, 2018

In general we've assumed that these are constants for the life of the program. It's unclear what would happen if some of these "run-time constants" started changing underfoot, even if we did all the wiring you suggest. It would probably be better to identify things that users really need to change and add explicit functions instead of reparsing $GODEBUG.

For example GODEBUG lets you set memprofilerate but there's a direct way to set it too.

/cc @aclements @RLH for whether it makes sense to be able to toggle gctrace, scavenge.

@rsc rsc added the WaitingForInfo label Dec 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment