Skip to content

proposal: runtime: flag to disable runtime override of GODEBUG #60943

@dpcollins-google

Description

@dpcollins-google

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:

  1. Split out debug itself and functions that modify debug.* fields into a new file, runtime/godebug.go
  2. Move all debug fields to top level variables named debug* and all their usages in the runtime/ package. These are not exported so should not be breaking.
  3. When the fixed_godebug flag is not empty, have cgo generate a replacement for godebug.go that replaces the var block with debug* values with a const block that sets all values inline, and makes all modifying functions log and do nothing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ProposalWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions