GODEBUG

GODEBUG is the controller of the variables and is used for debugging within the Go runtime. This variable contains a list of name=val key-value pairs, separated by commas. These named variables are used to tune the output of the debugging information the binary will return. One of the nice things about this variable is that the runtime allows you to apply this directly to a precompiled binary, rather than invoking it at build time. This is nice because it allows you to debug a binary that has already been built (and potentially already causing harm in a production environment). The variables you can pass to GODEBUG are as follows:

GODEBUG variables Enable value Description
allocfreetrace 1 Used in order to profile every allocation. A stack trace is printed for each object's allocation and is freed. Each stack trace contains the memory block, size, type, goroutine ID, and stack trace of the individual element.
clobberfree 1 The GC clobbers the content of an object with bad content when it frees the object.
cgocheck 0 Disabled 1 (default) Cheap checks 2 Expensive checks Checks for packages that use cgo for incorrectly passed go pointers to non-Go code.  Set 0 for disabled, 1 for cheap checks that may miss some errors (default), or 2 for expensive checks that will slow your program down.
efence 1 The allocator will ensure each object is allocated on a unique page and that memory addresses aren't recycled.
gccheckmark 1 Verifies the GC's current mark phase by doing a second mark pass. The world is stopped during this second mark pass. If the second pass finds an object that wasn't found by the concurrent mark, the GC will panic.
gcpacertrace 1 Prints information about the concurrent pacer's internal state with respect to the garbage collector.
gcshrinkstackoff 1 Moving goroutines cannot move onto smaller stacks. A Goroutine's stack only grows in this mode.
gcstoptheworld 1 – Disables GC 2 – Disables GC and concurrent sweeping 1 disables concurrent garbage collection. This turns each GC event into a stop the world situation. 2 disables GC and disables concurrent sweeping after the completion of garbage collection.
gctrace 1 See the GCTrace header on the subsequent page.
madvdontneed 1 Returns memory to the kernel with MADV_DONTNEED instead of MADV_FREE on Linux. Using this flag makes for less efficient memory utilization, but also makes RSS memory values drop more quickly.
memprofilerate 0 – Turn of profiling 1 – Include every allocated block X – Updates the value of MemProfileRate Controls memory allocation fractions that are reported and recorded within the memory profile. Changing X controls the fraction of memory allocations that are recorded.
invalidptr 0 – Disables this check 1 – Crashes if an invalid pointer is found The garbage collector and stack copier will crash if a value for an invalid pointer is found where a pointer is stored.
sbrk 1 Swaps in a trivial allocator from the OS that doesn't reclaim memory, instead of using the default memory allocator and garbage collector.
scavenge 1 The heap scavenger debugging mode is enabled.
scheddetail 1 (in conjunction with schedtrace=X) The scheduler returns information that pertains to the scheduler, processor, thread, and goroutine processes every X milliseconds.
schedtrace X A single line is emitted to STDERR every X milliseconds with a scheduler state summary.
tracebackancestors N Tracebacks of where goroutines are crated with their associated stacks are extended, reporting N ancestor goroutines. No ancestry information is returned if N = 0.

Other packages also have variables that are able to be passed to GODEBUG. These are usually very well-known packages that may need runtime performance tweaks, such as crypto/tls and net/http. Packages should contain documentation if they have GODEBUG flags that are available at runtime.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.20.224.107