Documentation
¶
Overview ¶
Package soak provides the pure metric primitives for the aether soak/chaos suite: bounded-memory latency percentiles, a windowed latency-trend check and a growth (leak) check. Nothing here touches NATS or an OS process, so it is fast to unit-test in normal CI, while the long-running orchestration that uses it lives behind the `soak` build tag in internal/lord.
Latencies are kept in fixed-bucket histograms rather than a growing slice: a soak run makes an unbounded number of calls, and because the lord runs in the same process as the test, an unbounded recorder would inflate the process heap and corrupt the very leak measurement the suite performs. Histograms make the recorder's footprint constant.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GrowthOK ¶
GrowthOK reports whether `end` stayed within tolerance above `start` (end <= start * (1+tolerance)). Used for goroutine counts, heap and thrall RSS: a leak shows up as unbounded growth over the run. A shrink or flat value passes. A non-positive start with a positive end is unbounded growth and fails.
Types ¶
type Bars ¶
type Bars struct {
LatP99Max time.Duration // sustained-load p99 ceiling (story: < 50ms)
TrendTol float64 // allowed rise of the last latency window over the first (fraction)
GrowthTol float64 // allowed growth of goroutines / heap / RSS end-vs-start (fraction)
// Resilience (v2).
RecoveryMax time.Duration // per-strategy recovery after a thrall kill (story: < 3s)
FailoverMax time.Duration // singleton failover after the holder dies (story: < 5s)
MaxLiveSingleton int // max live singleton instances allowed at once (fencing: 1)
}
Bars holds the pass/fail thresholds for a soak run. The defaults are the story's approved values; a run may tighten or loosen them per profile.
func DefaultBars ¶
func DefaultBars() Bars
DefaultBars returns the story's approved bars: p99 < 50ms, no upward latency trend beyond 20%, less than 10% resource growth after warm-up, chaos recovery within 3s, singleton failover within 5s, and never more than one live singleton.
type LatencyRecorder ¶
type LatencyRecorder struct {
// contains filtered or unexported fields
}
LatencyRecorder collects call latencies into an overall histogram plus per-window histograms so a trend (early vs late in the run) can be computed. It is safe for concurrent use: the load generator records from many goroutines at once. Memory is bounded by (windows+1) * histBuckets regardless of how many calls are recorded.
func NewLatencyRecorder ¶
func NewLatencyRecorder(total time.Duration, windows int) *LatencyRecorder
NewLatencyRecorder returns a recorder that spreads samples across `windows` equal time windows over the expected total run duration. Samples arriving after the last window fold into it, so an over-running phase never panics.
func (*LatencyRecorder) Add ¶
func (r *LatencyRecorder) Add(d time.Duration)
Add records one latency sample, placing it in the window for the current elapsed time.
func (*LatencyRecorder) Count ¶
func (r *LatencyRecorder) Count() uint64
Count returns the number of recorded samples.
func (*LatencyRecorder) Max ¶
func (r *LatencyRecorder) Max() time.Duration
Max returns the largest recorded sample, or 0 when empty.
func (*LatencyRecorder) Percentile ¶
func (r *LatencyRecorder) Percentile(p float64) time.Duration
Percentile returns the p-th percentile (0..100) over all samples.
func (*LatencyRecorder) Trend ¶
func (r *LatencyRecorder) Trend(p float64) Trend
Trend reports the p-th percentile of the earliest and latest windows that received samples. Comparing them surfaces a runtime that degrades over time. A run short enough to fill only one window yields First == Last (a flat, passing trend).
type Report ¶
type Report struct {
Profile string
Duration time.Duration
Seed int64
Bars Bars
// Sustained load.
CallCount int
LatP99 time.Duration
LatMax time.Duration
LatP99First time.Duration // p99 of the first latency window (trend baseline)
LatP99Last time.Duration // p99 of the last latency window
// Durable no-loss.
Published int
Distinct int
Duplicates int
// Leak deltas over the run's settled (back-half) region, so a working-set ramp is
// not mistaken for a leak. LeakEvaluated is false when the run was too short to
// reach a steady state: the deltas are then reported for information but not held
// to the growth bars.
LeakEvaluated bool
GoroutineStart int
GoroutineEnd int
HeapStart uint64 // bytes
HeapEnd uint64 // bytes
ThrallRSSStart map[string]int64 // KB, per thrall name
ThrallRSSEnd map[string]int64 // KB, per thrall name
// Chaos (v2): random thralls SIGKILLed under load; recovery = kill -> ready again.
Kills int
RecoveryP99 time.Duration
RecoveryMax time.Duration
// Singleton failover (v2): the lock holder killed repeatedly.
Failovers int
FailoverMax time.Duration
MaxLiveInstances int // most singleton instances seen live at once (fencing: must stay 1)
// Graceful drain (v2): a drain triggered mid-stream must lose no work.
DrainPublished int
DrainDelivered int
}
Report is the structured outcome of a soak run. Fields for a phase that did not run stay at their zero value, and Breaches skips a bar whose phase produced no data (e.g. a load-only smoke run leaves the durable and leak sections empty).