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
- Variables
- 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 Latency
- type LibraryOptions
- type LibraryTarget
- type Options
- type PacedOptions
- type PacedReport
- type Report
- type Sample
- type Target
- type Weighted
- type Window
- type Windows
Constants ¶
const SlowDelay = 2 * time.Second
SlowDelay is the time the "slow" exporter blocks on each Export call.
Variables ¶
var ErrPacedOptions = errors.New("invalid paced run options")
ErrPacedOptions is returned by RunPaced for options that cannot describe a run.
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 Latency ¶ added in v0.2.0
type Latency struct {
Requests int
Failures int
P50 time.Duration
P99 time.Duration
Max time.Duration
}
Latency summarises the answers of one class of requests.
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(ctx context.Context, opts 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 PacedOptions ¶ added in v0.2.0
type PacedOptions struct {
// Rate is the constant number of requests started per second (open loop: a slow answer does not delay the next
// request, and a latency is counted from the instant the request was due, not from when a worker took it).
Rate int
// Duration is the length of the run.
Duration time.Duration
// Workers is the number of goroutines that send the requests.
Workers int
// Tail extends every window past the instant the disturbance returned: the effects of a swap (the collection of
// the old generation) outlive the call that made it.
Tail time.Duration
}
PacedOptions configure RunPaced.
type PacedReport ¶ added in v0.2.0
type PacedReport struct {
Inside, Outside Latency
// Windows is the number of disturbances, and WindowTime the total time covered by their windows (with the tail).
Windows int
WindowTime time.Duration
Elapsed time.Duration
}
PacedReport is the result of RunPaced: the requests split by whether they were due inside a window.
func RunPaced ¶ added in v0.2.0
func RunPaced( ctx context.Context, t Target, opts PacedOptions, disturb func(context.Context, *Windows) error, ) (PacedReport, error)
RunPaced sends opts.Rate requests per second to t for opts.Duration while disturb runs on its own goroutine (it brackets each disturbance with Begin and End on the windows it is given, and returns when ctx ends or it fails). It returns the latency of the requests due inside the windows and outside them. The latency is the real elapsed time: the measure is the output of the 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. |
|
soak/soakapp
Package soakapp parses the command line and runs the load-test soak command.
|
Package soakapp parses the command line and runs the load-test soak command. |
|
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. |
|
Package segments holds the load and chaos tests of the dynamic segments against a real Valkey and a real relay proxy, started from the harness in internal/loadtest/relay.
|
Package segments holds the load and chaos tests of the dynamic segments against a real Valkey and a real relay proxy, started from the harness in internal/loadtest/relay. |