Documentation
¶
Overview ¶
Package guard bounds a native host process of the conformance gate: a request that runs too long, a heap that grows past a limit, or a parent that has gone. A core step is a synchronous call, so a step that never returns (a scheduler loop with no hop to the host) also never lets its parent time out: the parent blocks in a read, the gate kills the parent, and the child keeps allocating until the host is out of memory. The guard ends the child itself, names the request and writes the stack of every goroutine, so the row fails with its cause. Host processes only; no core package imports it.
Index ¶
Constants ¶
const ( EnvMemoryMB = "DCORE_CORE_MEM_LIMIT_MB" EnvStepSecs = "DCORE_CORE_STEP_TIMEOUT_S" )
Environment variables a gate run passes to the child (the gate forwards DCORE_*).
const ( ExitBound = 3 ExitParent = 4 )
Exit codes of a tripped guard. ExitBound is a runaway (reported on stderr); ExitParent is silent.
const ( DefaultMemoryMB = 2 * 1024 DefaultStepSecs = 120 )
Default bounds. The largest legitimate request (a cold open of the 3500-turn history) takes seconds and a few hundred MiB (W1-3500 stays under 384 MiB); four parallel hosts stay inside a lane's 12 GB.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Guard ¶
type Guard struct {
// contains filtered or unexported fields
}
Guard watches one process.
func Start ¶
Start begins watching. The watcher is a goroutine of the host process; call Stop to end it.
type Options ¶
type Options struct {
Name string // the process, for messages
MemoryBytes uint64 // the most the Go runtime may hold from the system
Step time.Duration // the longest one request may run
Parent int // the parent process ID; the process ends when it changes (re-parented to init)
Poll time.Duration // how often the bounds are checked (default 100 ms)
Exit func(code int)
Stderr io.Writer
}
Options of a Guard. A zero field disables that bound.