-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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: flag to disable runtime override of GODEBUG #60943
Comments
Why add it to the cgo tool? |
I'm not super picky about where its added, is there a better place you would suggest to perform this manipulation? |
I don't understand what cgo has to do with this at all. More importantly, you said what you want, but you didn't say why you want it. What is the goal here? What is the problem being solved? Thanks. |
some piece of tooling needs to swap out the godebug.go file inside of the go runtime that has:
to:
Is there a better piece of the compiler ecosystem to do this?
Based on horizontal profiling, a lot of cycles are spent within the go garbage collector (and presumably in other places in the core runtime) on performing boolean checks that would be removed via constant propagation if the debug variables were constants. I would like to allow users (like myself) who don't want these debug checks to reduce the overhead of the go runtime further by disabling these constants at compile time instead of runtime. |
Maybe there is some terminology issue here. In the Go ecosystem cgo refers to https://pkg.go.dev/cmd/cgo. That tool is not going to be swapping out any files in the Go runtime. That's not what it's for. But this is a detail.
If that is the only goal here, then our first step should be to try to analyze this problem and see if we can fix it in the compiler or runtime in some way, without having to change the semantics of |
Yes, this is my fault. I think the tool I should have referenced was
The problem trying to be fixed is: there exist runtime branches and checks in compiled go code (in the garbage collector in particular) that incur a lot of cost, but only exist because |
Generally these If I'm wrong, that's great, and that's nice low-hanging fruit, but I'd like to see some more evidence that these debug variables are actually impacting performance. It would be pretty straightforward to patch out certain branches and run some of our benchmarks just to get an idea of the difference. Also, I think the right thing to do for at least some of these, if they were to become compile-time constants, would be to turn them into |
I would like to make a change to the go runtime to convert the debug variables parsed from GODEBUG to constants, and disable
GODEBUG
overriding at runtime.Many of these constants are used to gate low level checks in the depths of the garbage collector or runtime, and if they were true constants, some of these checks could be elided by constant propagation. An example is the findobject function which would be able to skip some checks if
debug.invalidptr
were known to be a fixed constant 0. (internal reference b/288410395, these have substantial cost)I would like to propose a new flag to
cgo
, strawmanfixed_godebug
, that when provided generates constant values for these fields as-if theGODEBUG
env var had the value offixed_godebug
at runtime.The work needed to implement this would be:
debug
itself and functions that modifydebug.*
fields into a new file,runtime/godebug.go
debug
fields to top level variables nameddebug*
and all their usages in the runtime/ package. These are not exported so should not be breaking.fixed_godebug
flag is not empty, havecgo
generate a replacement for godebug.go that replaces thevar
block withdebug*
values with aconst
block that sets all values inline, and makes all modifying functions log and do nothing.The text was updated successfully, but these errors were encountered: