You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The codebase has no *_test.go benchmarks. Every performance discussion (this issue, #11, and the proposed fixes in #21) ends up arguing about ballpark numbers. A small benchmark suite gives a real baseline before any rework and prevents regressions after.
Scope
Add Benchmark* functions covering the per-check hot paths and the metric pipeline. Suggested set:
BenchmarkCheck (destinations_bench_test.go) — full Check() against localhost with a stub statsd drain. Measures end-to-end per-check overhead including DNS, routing, dial, HTTPS.
BenchmarkLookup (resolver_bench_test.go) — pure DNS path. Pairs with #-DNS-caching once filed.
BenchmarkGetRoute (router_bench_test.go) — quantifies routing.New() per-call cost. Pairs with the routing-table-cache issue.
BenchmarkDestinationIncrement + BenchmarkTagsRebuild (destinations_bench_test.go) — allocations in the metric tag path. Pairs with the dest.tags() caching issue.
BenchmarkMonitorThroughput — simulates 100/500/1000 destinations to measure goroutine + GC + statsd-queue behavior with b.RunParallel and a stub server.
Helpful conventions
All benchmarks call b.ReportAllocs() so allocs/op is in the output.
Use testing.B.Run(name, ...) to parameterize by destination count for the monitor-throughput benchmark.
Add a make bench target (or ./build.sh bench) running go test -bench=. -benchmem ./....
Optionally wire into CI as a smoke run (-benchtime=1x) and a separate manual go test -bench=. -benchtime=10s workflow for serious measurement.
Stub statsd sink
Most of the above benchmarks need a way to keep the queue <- s send from blocking. Two options:
// Option A: drain into /dev/nullfuncinit() { gofunc() { forrangequeue {} }() }
// Option B: replace the sender for the test
Either works; Option B is cleaner once #11 lands and the sender becomes an interface.
Summary
The codebase has no
*_test.gobenchmarks. Every performance discussion (this issue, #11, and the proposed fixes in #21) ends up arguing about ballpark numbers. A small benchmark suite gives a real baseline before any rework and prevents regressions after.Scope
Add
Benchmark*functions covering the per-check hot paths and the metric pipeline. Suggested set:BenchmarkCheck(destinations_bench_test.go) — fullCheck()againstlocalhostwith a stub statsd drain. Measures end-to-end per-check overhead including DNS, routing, dial, HTTPS.BenchmarkLookup(resolver_bench_test.go) — pure DNS path. Pairs with #-DNS-caching once filed.BenchmarkGetRoute(router_bench_test.go) — quantifiesrouting.New()per-call cost. Pairs with the routing-table-cache issue.BenchmarkDestinationIncrement+BenchmarkTagsRebuild(destinations_bench_test.go) — allocations in the metric tag path. Pairs with thedest.tags()caching issue.BenchmarkStatsdSender(statsd_bench_test.go) — connection-per-metric cost; needs a UDP listener on127.0.0.1:0as a sink. Pairs with Statsd emitter can stall checks when statsd is down; opens a new connection per metric #11.BenchmarkGetLocalIPs(source_bench_test.go) — quantifies the per-log-line cost flagged in Logs are unstructured plain text without levels;GetLocalIPsruns per log line #21.BenchmarkMonitorThroughput— simulates 100/500/1000 destinations to measure goroutine + GC + statsd-queue behavior withb.RunParalleland a stub server.Helpful conventions
b.ReportAllocs()so allocs/op is in the output.testing.B.Run(name, ...)to parameterize by destination count for the monitor-throughput benchmark.make benchtarget (or./build.sh bench) runninggo test -bench=. -benchmem ./....-benchtime=1x) and a separate manualgo test -bench=. -benchtime=10sworkflow for serious measurement.Stub statsd sink
Most of the above benchmarks need a way to keep the
queue <- ssend from blocking. Two options:Either works; Option B is cleaner once #11 lands and the sender becomes an interface.
Why bother
log/slogper Logs are unstructured plain text without levels;GetLocalIPsruns per log line #21).Related
Cross-references: #11 (statsd sender), #21 (
GetLocalIPsper log line), plus the three perf issues filed alongside this one.