-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Description
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, strawman fixed_godebug, that when provided generates constant values for these fields as-if the GODEBUG env var had the value of fixed_godebug at runtime.
The work needed to implement this would be:
- Split out
debugitself and functions that modifydebug.*fields into a new file,runtime/godebug.go - Move all
debugfields to top level variables nameddebug*and all their usages in the runtime/ package. These are not exported so should not be breaking. - When the
fixed_godebugflag is not empty, havecgogenerate a replacement for godebug.go that replaces thevarblock withdebug*values with aconstblock that sets all values inline, and makes all modifying functions log and do nothing.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status