Documentation
¶
Overview ¶
Package report turns a finished load run into the files an operator reads: the run record (run.json), summary.md and series.csv, the findings rules that flag suspicious behavior, run-against-run comparison, the merge of shard records and the knee of a sweep.
The record is the contract between the runner, which fills it, and the commands that read it back (compare, merge, sweep). The names of its histograms and counters are constants in this package so the runner and the rules agree on them.
Index ¶
- Constants
- func CompareWarnings(a, b *Record) []string
- func Knee(points []SweepPoint) (index int, reason string)
- func RenderDeltas(ds []Delta) string
- func StreamCapMB(sc *scenario.Scenario) float64
- func WriteSweep(dir, varied string, pts []SweepPoint) error
- type Backlog
- type Delta
- type Env
- type FaultRecord
- type Finding
- type Reclaims
- type Record
- type Rework
- type ShardSpec
- type SweepPoint
Constants ¶
const ( VerdictBetter = "better" VerdictWorse = "worse" VerdictNoChange = "no change" )
Compare verdicts.
const ( SeverityWarn = "warn" SeverityError = "error" )
Finding severities. An "error" is something that makes the run's result unreliable or points at a defect in sqi: dropped pushes, a throttled generator, workers lost without cause, or a leak large enough to end in an out-of-memory kill. A "warn" is something to look at that does not on its own invalidate the run. Neither changes the run's exit status, which only invariants, validity and completeness decide.
const ( RuleGoroutineGrowth = "goroutine-growth" RuleRSSGrowth = "rss-growth" RuleWALNeverShrank = "wal-never-shrank" RuleWSDrops = "ws-drops" RuleRateLimited = "rate-limited" RuleStreamAtCap = "stream-at-cap" RuleWorkersOffline = "workers-offline-under-load" RuleRejected = "submissions-rejected" RuleFellBehind = "server-fell-behind" // The runner's own rules, which read what only a live run knows (the // fleet's churn, the --allow-saturated flag) and so cannot be recomputed // from a record: Merge carries them over from the shards. RuleChurnFailed = "churn-failed" RuleGeneratorSaturated = "generator-saturated" )
Finding rule names.
const ( ModeLoad = "load" ModeSoak = "soak" ModeSweepPoint = "sweep-point" )
Run modes.
const ( // HistSubmitLatency is the HTTP round trip of a job submission. HistSubmitLatency = "submit_latency" // HistSubmitLag is how late a paced submission left the generator. HistSubmitLag = "submit_lag" // HistFirstLease is the time from a job's submission to its first task's // lease; driver.Metrics.FirstLease. A sweep's knee reads its p95. HistFirstLease = "first_lease" // HistTaskE2E is one simulated attempt from its lease reaching the worker // to the worker publishing its terminal status. It holds the scenario's // sampled task duration, so it describes the input as much as the server. HistTaskE2E = "task_e2e" // HistTerminalIngest is how long the server took to store a task's // terminal status: the task's updated_at once terminal minus the moment // the simulated worker published that status. A clock difference between // the generator and an attached server shifts it. HistTerminalIngest = "terminal_ingest" // HistJobE2E is a job's submission to its terminal status. HistJobE2E = "job_e2e" // HistWSLag is the WebSocket push lag. HistWSLag = "ws_lag" // HistRESTPrefix prefixes a REST poller endpoint's histogram key. HistRESTPrefix = "rest." )
Keys of Record.Histograms. They match the fields of driver.Metrics.
const ( // CounterTasksTerminal counts distinct tasks that reached a terminal // status on the server. CounterTasksTerminal = "tasks.terminal" // CounterJobsSubmitted counts jobs the server accepted. CounterJobsSubmitted = "jobs.submitted" // CounterLogLines counts the task log lines the simulated workers emitted // in the attempts that have ended: the log load offered to the server. // Whether the server kept them is the logs invariant's question. CounterLogLines = "logs.lines" // CounterWorkersLive is the size of the simulated fleet that was meant to // be online (a gauge, not a flow: it is not turned into a rate). CounterWorkersLive = "workers.live" // CounterWSDrops counts WebSocket pushes a client missed. CounterWSDrops = "ws.drops" // CounterWSEvents counts WebSocket pushes received. CounterWSEvents = "ws.events" // CounterWSLagNegative counts WebSocket pushes stamped later than they // arrived, left out of the lag histogram: a sign of clock skew between // the generator and the server. CounterWSLagNegative = "ws.lag_negative" // CounterWSErrors counts failed WebSocket dials and broken connections. CounterWSErrors = "ws.errors" // CounterRESTErrors counts failed poller calls. CounterRESTErrors = "rest.errors" // CounterSubmitStatusPrefix prefixes the count of submissions answered with // one HTTP status, for example "submit.status.429". CounterSubmitStatusPrefix = "submit.status." )
Keys of Record.Counters. The runner fills them from driver.Metrics and the verifier; the findings rules and the throughput figures read them.
Variables ¶
This section is empty.
Functions ¶
func CompareWarnings ¶
CompareWarnings returns a warning for each of the two records a comparison cannot trust: one that is INVALID, whose numbers describe a saturated generator rather than the server, or one that is incomplete, whose counters and histograms stop early. The deltas are still computed; the warnings say what they are worth.
func Knee ¶
func Knee(points []SweepPoint) (index int, reason string)
Knee finds where a sweep's farm stopped coping. points are in ascending order of the varied value and the first is the baseline. The knee is the first point whose run was INVALID (the generator saturated), whose invariants failed, or whose submit-to-first-lease p95 exceeds twice the baseline's. It returns the point's index and the reason, or -1 and a note when there is no knee. A point with no record is the knee, with the reason "missing record". A point with no first-lease histogram is not judged on latency, and neither is any point when the baseline has none or a zero p95.
func RenderDeltas ¶
RenderDeltas formats deltas as an aligned text table.
func StreamCapMB ¶
StreamCapMB is the JetStream store cap the run's server was configured with: nats.embedded.max_store_mb from the scenario's server config, else the server default.
func WriteSweep ¶
func WriteSweep(dir, varied string, pts []SweepPoint) error
WriteSweep writes sweep.csv and sweep.md into dir: one row per point with the throughput and the first-lease p50, p95 and p99, whether the run was valid and whether its invariants held, and the knee called out in the table. varied names the parameter that was swept.
Types ¶
type Backlog ¶
type Backlog struct {
// Open is the number of the farm's tasks not yet terminal at WindowEnd.
Open int64 `json:"open"`
// TailCompleted is the number of tasks that reached a terminal status in
// the last tenth of the measured window, from TailFrom to WindowEnd.
TailCompleted int64 `json:"tail_completed"`
TailFrom time.Time `json:"tail_from"`
}
Backlog compares the work left open when submissions stopped with how fast the server was finishing work just before.
type Delta ¶
type Delta struct {
Metric string
A, B float64
// Pct is (B-A)/A*100. When A is zero it is 0 if B is zero too, and +Inf
// otherwise (a metric that is "new" in B).
Pct float64
Verdict string
}
Delta is one metric's change from run A to run B.
func Compare ¶
Compare returns the per-metric deltas from a to b: the p50, p95 and p99 of every histogram both runs have, every comparable counter (as a per-second steady-window rate when both runs carry a SteadyCounters snapshot, as a per-second run average when either does not, and as a total when a run has no duration) and the peaks of the key server series. A difference of at most 5% either way is "no change". Deltas come in a fixed order: histograms, counters, peaks.
type Env ¶
type Env struct {
OS string `json:"os"`
Arch string `json:"arch"`
CPUs int `json:"cpus"`
SQIVersion string `json:"sqi_version"`
Commit string `json:"commit"`
Store string `json:"store"`
Flags []string `json:"flags"`
}
Env describes where a run happened.
type FaultRecord ¶
type FaultRecord struct {
// Index is the fault's position in the scenario's faults.
Index int `json:"index"`
Kind string `json:"kind"`
// Target is what the fault hit: "server", "group render (real 0,1)",
// "groups [rack-b]" or "all".
Target string `json:"target"`
// ServerRestart is set when the fault stopped the server's process and
// started it again (a kill, a term or a power cut), so the server's broker
// connection came up again when it healed. A stall leaves the process,
// and its connection, in place.
ServerRestart bool `json:"server_restart,omitempty"`
// Workers are the IDs of the real workers a revoke hit.
Workers []string `json:"workers,omitempty"`
// Notes are what the controller observed while the fault was applied, for
// example the server's readiness during a full data volume.
Notes []string `json:"notes,omitempty"`
Start time.Time `json:"start"`
// Healed is zero when the fault never healed: a worker left dead, an
// error, or a run interrupted before the heal.
Healed time.Time `json:"healed"`
Error string `json:"error,omitempty"`
}
FaultRecord is one fault the run injected: when it fired and when it healed.
type Finding ¶
type Finding struct {
Rule string `json:"rule"`
Severity string `json:"severity"`
Message string `json:"message"`
}
Finding is one thing the rules flagged about a run.
type Reclaims ¶
type Reclaims struct {
Attempts int `json:"attempts"`
// ByReason counts them by the message the server recorded.
ByReason map[string]int `json:"by_reason,omitempty"`
// Examples are the first few, at most 20.
Examples []string `json:"examples,omitempty"`
}
Reclaims are the attempts the server closed as failed to take their tasks back from a worker, as the stopped server's store records them: a worker the heartbeat sweep marked offline, one that shut down or stopped reporting the attempt, or one that re-registered from a new process.
type Record ¶
type Record struct {
RunID string `json:"run_id"`
// Mode is ModeLoad, ModeSoak or ModeSweepPoint.
Mode string `json:"mode"`
// Shard is "i/n" for a shard of a multi-generator run, "" otherwise.
Shard string `json:"shard,omitempty"`
// Complete is false when the run ended before its planned duration.
Complete bool `json:"complete"`
// Valid is false when the measurement cannot be trusted, typically because
// the generator was saturated; InvalidReason says why.
Valid bool `json:"valid"`
InvalidReason string `json:"invalid_reason,omitempty"`
// Scenario is the scenario as resolved. In a record merged from shards it
// is shard 0's, whose counts and rates are per shard, not for the whole
// farm.
Scenario *scenario.Scenario `json:"scenario"`
Env Env `json:"env"`
// Started is when submissions began, Ended when the run's jobs had
// drained (or the drain timed out) and its invariants were about to be
// checked.
Started time.Time `json:"started"`
Ended time.Time `json:"ended"`
// WindowEnd is when submissions stopped: the end of the measured window,
// which runs from SteadyFrom to WindowEnd. The run drains from WindowEnd
// to Ended. Zero (a record without it, or a run stopped before
// submissions ended) makes the window end at Ended.
WindowEnd time.Time `json:"window_end"`
// Histograms cover the whole run, warmup included.
Histograms map[string]*measure.Histogram `json:"histograms"`
// Counters are the counter values at the end of the run.
Counters map[string]int64 `json:"counters"`
// SteadyCounters are the counter values at SteadyFrom, snapshotted by the
// runner. A rate over the measured window is (WindowCounters -
// SteadyCounters) divided by WindowEnd - SteadyFrom. Nil (no snapshot,
// as with warmup 0) makes every rate a run average, WindowCounters over
// WindowEnd - Started.
SteadyCounters map[string]int64 `json:"steady_counters"`
// WindowCounters are the counter values at WindowEnd, with every key of
// Counters. Nil (no snapshot) means Counters.
WindowCounters map[string]int64 `json:"window_counters"`
// Backlog is the work the server still held when submissions stopped,
// beside its recent pace; nil when it could not be read.
Backlog *Backlog `json:"backlog,omitempty"`
Series []measure.Series `json:"series"`
Invariants []verify.Result `json:"invariants"`
Findings []Finding `json:"findings"`
// Faults are the faults the run injected, in scenario order; empty for a
// run without faults.
Faults []FaultRecord `json:"faults,omitempty"`
// Rework is the work faults made the farm do twice; nil when the run did
// not measure it (a run without chaos checks, or a store it could not read).
Rework *Rework `json:"rework,omitempty"`
// Reclaims are the attempts the server took back from a worker; nil when
// the run did not measure them (as for Rework).
Reclaims *Reclaims `json:"reclaims,omitempty"`
}
Record is everything one run measured. It is what run.json holds.
func Merge ¶
Merge combines the records of one run's shards into one record. The records must share a run ID. In the merged record:
- histograms merge, and counters and backlogs add;
- SteadyCounters and WindowCounters add like Counters, unless a shard has none, in which case the merged record has none (no SteadyCounters makes its rates run averages);
- series, environment and scenario come from shard 0/n, the shard that carries server observations, so the scenario's counts and rates are per shard, not for the whole farm;
- Started is the earliest shard's, Ended and WindowEnd the latest shard's;
- the run is Valid and Complete only if every shard is;
- an invariant holds only if it held in every shard, with the shards' evidence concatenated;
- findings are recomputed from the merged data, and the runner's own (churn-failed, generator-saturated), which a record cannot recompute, are carried over from the shards.
The inputs are not modified.
func (*Record) Drain ¶
Drain is how long the run waited, after submissions stopped, for its jobs to finish: Ended - WindowEnd, or 0 when the record has no WindowEnd.
func (*Record) MeasuredEnd ¶
MeasuredEnd is the end of the measured window: WindowEnd, or Ended when the record has none.
func (*Record) NoneAccepted ¶
NoneAccepted reports whether the run's scenario submits jobs but the server accepted none of them. Every invariant holds vacuously on such a run, so it says nothing about the server: a key without jobs.write, a template the server refuses, or every submission throttled.
func (*Record) SteadyFrom ¶
SteadyFrom is when the steady-state window starts: the run's start plus the scenario's warmup.
type Rework ¶
type Rework struct {
Attempts int `json:"attempts"`
Seconds float64 `json:"seconds"`
// ByFault maps a fault's index to the attempts attributed to it: the latest
// fault that began before the attempt's worker-side end.
ByFault map[int]int `json:"by_fault,omitempty"`
// Examples are the first few, at most 20.
Examples []string `json:"examples,omitempty"`
// Undercount, when set, says why Attempts leaves out some real tasks'
// executions, so the count is a lower bound.
Undercount string `json:"undercount,omitempty"`
}
Rework is the attempts that ran to completion on a worker and still did not count: the server recorded another outcome for a simulated worker's, or a real task's process finished more times than the server credited.
type ShardSpec ¶
type ShardSpec struct{ Index, Of int }
ShardSpec names one slice of a scenario run from several generator machines: shard Index of Of, counting from 0. The zero value, like any Of below 2, is the whole scenario.
func ParseShard ¶
ParseShard reads "i/n", with 0 <= i < n.
func (ShardSpec) Apply ¶
Apply returns this shard's slice of sc, leaving sc unchanged. Worker counts (simulated and real), ramp rates, job rates and totals, and the numbers of WebSocket clients and REST pollers are divided between the shards, remainders going to shard 0. Each shard creates its own farm, so a queue's concurrency cap is divided too, and a capped queue keeps a cap of at least 1 in every shard (0 is unlimited). Usage pools are global and shared by name across the shards, so their limits are not divided. A job class whose total divides to 0 in this shard, and that has no rate, is left out of it.
type SweepPoint ¶
SweepPoint is one run of a sweep: the value of the varied parameter and the record of the run made with it.