Documentation
¶
Overview ¶
Package bench is the engine benchmark suite: Hysteria2, VLESS (REALITY over TCP and over XHTTP) and AmneziaWG, each between two network namespaces joined by a veth pair (with netem variants), measured for throughput, CPU per gigabyte, latency under load, memory and handshakes per second. The suite itself is in the *_test.go files behind the build tag "bench" and runs only on Linux, as root, with MISTGATE_BENCH=1 (see docs/en/reference/benchmarks.md and scripts/bench.sh). This file is the part that needs none of that: the report format and the comparison against the committed baseline, which is plain Go and is tested on every OS.
Index ¶
Constants ¶
const DefaultThreshold = 0.15
DefaultThreshold is how much worse than the baseline a metric may get before the run fails: 15 percent.
const SchemaVersion = 1
SchemaVersion is the version of the report format. A baseline of another version is not compared.
const ThresholdEnv = "MISTGATE_BENCH_THRESHOLD"
ThresholdEnv names the environment variable that overrides the threshold: "20" or "20%" or "0.2" all mean 20 percent.
Variables ¶
This section is empty.
Functions ¶
func ParseThreshold ¶
ParseThreshold reads a threshold given as "15", "15%" or "0.15" (everything above 1 is a percentage). An empty string is the default. A value that is not a positive number is an error: a typo must not silently turn the check off.
func ThresholdFromEnv ¶
ThresholdFromEnv is ParseThreshold of the environment variable.
Types ¶
type Finding ¶
type Finding struct {
Case, Metric string
Baseline, Got float64
ChangePct float64 // positive = worse
HigherIsBetter bool
}
Finding is one metric of one case that got worse than the threshold allows.
type Metrics ¶
type Metrics struct {
// Throughput of 1 and of 8 parallel streams, Mbit/s, client to internet direction as seen by the client (a download).
Tput1Mbit float64 `json:"tput_1_mbit_s,omitempty"`
Tput8Mbit float64 `json:"tput_8_mbit_s,omitempty"`
// CPUSecPerGB is the CPU time the engine process used (user plus system) per gigabyte it moved in both throughput phases.
CPUSecPerGB float64 `json:"cpu_s_per_gb,omitempty"`
// P50MS and P99MS are the latency of a small request while 8 streams are loading the link.
P50MS float64 `json:"p50_ms,omitempty"`
P99MS float64 `json:"p99_ms,omitempty"`
// RSSMB is the engine process's peak resident memory after the run.
RSSMB float64 `json:"rss_mb,omitempty"`
// HandshakesPerS is how many new sessions per second a client can complete. For AmneziaWG it is a re-handshake of one peer
// with one ping, paced at WireGuard's own flood limit (one initiation per 20 ms), so it tops out near 30 and mostly shows
// that every one of them succeeds.
HandshakesPerS float64 `json:"handshakes_per_s,omitempty"`
}
Metrics is what one case measured. A zero value is "not measured" (a case that could not measure it) and is never compared.
func MedianOf ¶
MedianOf is the metric-by-metric median of several runs of one case (a metric a run did not measure is left out of its own median; an even count takes the mean of the middle two). One run of a throughput test on a shared machine can be off by a third, so a baseline is best made from three or five.
type Report ¶
type Report struct {
Schema int `json:"schema"`
When string `json:"when,omitempty"`
Host string `json:"host,omitempty"` // kernel, CPU count and Go version: a baseline only means something on the same kind of machine
// Cases is keyed "<engine>/<variant>": hysteria2/clean, vless-tcp/rtt50-loss1, awg/mtu1280 and so on.
Cases map[string]Metrics `json:"cases"`
}
Report is the JSON the suite writes.
func LoadReport ¶
LoadReport reads a report (or the baseline) from a file.
type Result ¶
type Result struct {
Regressions []Finding
// Notes are things worth saying that do not fail the run: a case without a baseline, a baseline case that was not run.
Notes []string
}
Result is the outcome of a comparison.
func Compare ¶
Compare checks got against baseline. A metric fails when it is worse than the baseline by more than threshold (a fraction: 0.15 is 15 percent) and by more than its minimum absolute change. Better is never a failure. A case or a metric missing on one side is a note, not a failure, so a new engine does not need a baseline first.