Documentation
¶
Overview ¶
Package loadtest contains the flag fixtures, the exporter behaviours and the soak harness used to measure the throughput and the memory stability of semaphore. See README.md in this directory.
Index ¶
- Constants
- func FlagKey(scenario, typ string, track bool) string
- func FlagsYAML() string
- func ManyFlagsYAML(n int) string
- func Scenarios() []string
- func Types() []string
- type Exporter
- type ExporterMode
- type LibraryOptions
- type LibraryTarget
- type Options
- type Report
- type Sample
- type Target
- type Weighted
- type Window
Constants ¶
const SlowDelay = 2 * time.Second
SlowDelay is the time the "slow" exporter blocks on each Export call.
Variables ¶
This section is empty.
Functions ¶
func FlagKey ¶
FlagKey returns the key of the generated flag for a scenario, a type and the tracking mode.
func FlagsYAML ¶
func FlagsYAML() string
FlagsYAML returns a flag configuration (YAML) with one flag per scenario, type and tracking mode. Keys are given by FlagKey.
func ManyFlagsYAML ¶
ManyFlagsYAML returns n simple flags named flag-0 .. flag-(n-1), mixing static, targeting and percentage flags, used for the all-flags benchmarks.
Types ¶
type Exporter ¶
type Exporter struct {
Mode ExporterMode
Delay time.Duration
Batches atomic.Int64
Events atomic.Int64
Failures atomic.Int64
}
Exporter is a bulk exporter with a configurable behaviour that counts what it received.
func NewExporter ¶
func NewExporter(mode ExporterMode) *Exporter
NewExporter creates an Exporter for the mode.
type ExporterMode ¶
type ExporterMode string
ExporterMode selects the behaviour of the exporter used by the harness and the benchmarks.
const ( // ExporterDiscard accepts and drops every batch immediately. ExporterDiscard ExporterMode = "discard" // ExporterSlow sleeps for SlowDelay on every batch before accepting it. ExporterSlow ExporterMode = "slow" // ExporterFailing returns an error on every batch. ExporterFailing ExporterMode = "failing" )
func ParseExporterMode ¶
func ParseExporterMode(s string) (ExporterMode, error)
ParseExporterMode validates an exporter mode name.
type LibraryOptions ¶
type LibraryOptions struct {
FlagKey string
ExporterMode ExporterMode
FlushInterval time.Duration
MaxEventInMemory int64
}
LibraryOptions configure NewLibraryTarget.
type LibraryTarget ¶
type LibraryTarget struct {
// contains filtered or unexported fields
}
LibraryTarget evaluates a bool flag through the embedded library with event tracking.
func NewLibraryTarget ¶
func NewLibraryTarget(o LibraryOptions) (*LibraryTarget, error)
NewLibraryTarget starts a library client on the generated flags.
func (*LibraryTarget) Eval ¶
func (l *LibraryTarget) Eval(worker, i int) error
Eval implements Target.
func (*LibraryTarget) Extra ¶
func (l *LibraryTarget) Extra() map[string]int64
Extra implements Target.
type Options ¶
type Options struct {
Name string
Duration time.Duration
// Interval is the sampling period (default 5s).
Interval time.Duration
// Workers is the number of goroutines evaluating at max rate (default GOMAXPROCS).
Workers int
// WarmupIntervals is the number of leading samples ignored by the verdict
// (default max(2, 20% of the samples)).
WarmupIntervals int
// HeapTolerance is the maximum relative growth of the median post-GC HeapInuse between the first and
// the last half of the measured window (default 0.25 = 25%).
HeapTolerance float64
// HeapMinGrowthBytes is an absolute allowance under which growth never fails (default 32 MiB).
HeapMinGrowthBytes uint64
// GoroutineSlack is the number of goroutines the count may exceed its value at the end of the
// warm-up by (default 64).
GoroutineSlack int
// MaxHeapBytes aborts the run (verdict FAIL) when the live heap exceeds it, to protect the
// machine from an unbounded leak (default 6 GiB).
MaxHeapBytes uint64
}
Options configure Run.
type Report ¶
type Report struct {
Extra map[string]int64
Name string
Samples []Sample
Reasons []string
// Window is the throughput and latency of the measured window; the zero value when it is too short.
Window Window
TotalEval int64
TotalErr int64
// HeapGrowthBytes is the growth of the median HeapInuse between the first and the last half of the measured window.
HeapGrowthBytes float64
Pass bool
}
Report is the result of Run.
type Sample ¶
type Sample struct {
Elapsed time.Duration
EvalsPerSec float64
Errors int64
P50, P99 time.Duration
HeapAlloc uint64 // after a forced GC
HeapInuse uint64 // after a forced GC
HeapObjects uint64 // after a forced GC
NumGC uint32
Goroutines int
}
Sample is one line of the time series.
type Target ¶
type Target interface {
// Eval does one evaluation. i is a per-worker increasing counter.
Eval(worker, i int) error
// Extra returns target specific counters that are printed at the end of the run (optional).
Extra() map[string]int64
// Close releases the resources of the target.
Close()
}
Target is something we can evaluate flags against.
type Weighted ¶
type Weighted interface {
// FlagsPerCall is the number of flags one successful call evaluates (at least 1).
FlagsPerCall() int
}
Weighted is implemented by a target whose call evaluates several flags (a bulk request): the report then also gives flags evaluated per second.
type Window ¶
type Window struct {
// Samples is the number of sampling intervals in the window.
Samples int
// CallsPerSec is the mean number of calls (requests) per second.
CallsPerSec float64
// FlagsPerCall is the number of flags evaluated by one call (1 unless the target is Weighted).
FlagsPerCall int
// FlagsPerSec is CallsPerSec * FlagsPerCall.
FlagsPerSec float64
// Errors is the number of failed calls in the window.
Errors int64
// P50, P95, P99 are latency quantiles of the sampled calls of the window (upper bound of the bucket).
P50, P95, P99 time.Duration
}
Window summarizes the measured part of a run (the samples after the warm-up).
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
soak
command
Command soak runs a max-rate load against the library or a real relay proxy (loopback HTTP), with event tracking on and a selectable exporter behaviour, and prints a time series and a "memory stable" verdict.
|
Command soak runs a max-rate load against the library or a real relay proxy (loopback HTTP), with event tracking on and a selectable exporter behaviour, and prints a time series and a "memory stable" verdict. |
|
Package relay starts an in-process relay proxy for the benchmarks and the soak harness.
|
Package relay starts an in-process relay proxy for the benchmarks and the soak harness. |