Documentation
¶
Overview ¶
Package benchmark implements a synchronous steady-state pipeline for load-testing the Flow Control layer.
Benchmarking Flow Control is challenging. Data plane routing is fast, while downstream inference is slow. Simulating downstream latency with thread sleeps skews CPU profiles by parking goroutines, which measures Go scheduler overhead rather than computational throughput.
This harness avoids sleeps by using a synchronous pipeline:
- Intentional Backpressure (W > L): Ingress Concurrency (W) is driven higher than the Capacity Limit (L), forcing requests to queue.
- Strict Capacity Checking: A mock SaturationDetector atomically grants capacity only when evaluated, preventing race conditions where dispatch outruns clients.
- Immediate Draining: When a client unblocks, it immediately frees its capacity slot, triggering the next dispatch and keeping the system continuously active.
- Consistent Queue Depth: Maintaining a fixed, deep queue forces continuous evaluation of fairness and ordering policies at limits, isolating CPU performance.
Interpreting Metrics in b.RunParallel ¶
In a highly concurrent queuing system, standard Go benchmark metrics require careful interpretation:
- ns/op (system-wide amortized time): Because this uses b.RunParallel, ns/op represents inverse throughput, not latency. If the system processes 1,000,000 requests in 1 second, it reports 1,000,000 ns/op. (The d/s custom metric converts this to RPS automatically).
- ops (the definition of an operation): One "op" is the complete lifecycle of a single simulated request: Ingress, queuing, policy evaluation, and egress.
- allocs/op and B/op (GC Pressure): High allocations per request mean the Go Garbage Collector will thrash under load, causing latency jitter.
- Saturated Coordinates (W > L): When Concurrency (W) exceeds Capacity (L), EnqueueAndWait blocks. Because we immediately release capacity upon dispatch, the duration of an "op" is strictly governed by the Flow Control layer's CPU overhead.
Custom Metrics Reported ¶
- d/s: (Dispatches/sec) The primary throughput metric.
- r/s: (Rejects/sec) Rate of requests rejected due to capacity or timeouts.
- errors: Total unexpected runtime errors encountered.
- zombies/s: Rate of requests hitting context deadlines/TTLs.
- burst_dispatches/sec: Drain rate when capacity is instantaneously freed.
Click to show internal directories.
Click to hide internal directories.