forked from mirror/client_golang
1b2bd1d665
Fixes #275 This is rather tricky and required some studying of the Go memory model. I have added copious code comments to explain what's going on. Benchmarks haven't changed significantly, despite the additional atomic operations now required during Observe. Write performance is noticable, but it is also much more involved now and has a mutex. (But note that Write is supposed to be a relatively rare operation and thus not in the hot path compared to Observe.) Allocs haven't changed at all. OLD: BenchmarkHistogramWithLabelValues-4 10000000 151 ns/op 0 B/op 0 allocs/op BenchmarkHistogramNoLabels-4 50000000 36.0 ns/op 0 B/op 0 allocs/op BenchmarkHistogramObserve1-4 50000000 28.1 ns/op 0 B/op 0 allocs/op BenchmarkHistogramObserve2-4 10000000 160 ns/op 0 B/op 0 allocs/op BenchmarkHistogramObserve4-4 5000000 378 ns/op 0 B/op 0 allocs/op BenchmarkHistogramObserve8-4 2000000 768 ns/op 0 B/op 0 allocs/op BenchmarkHistogramWrite1-4 1000000 1589 ns/op 896 B/op 37 allocs/op BenchmarkHistogramWrite2-4 500000 2973 ns/op 1792 B/op 74 allocs/op BenchmarkHistogramWrite4-4 300000 6979 ns/op 3584 B/op 148 allocs/op BenchmarkHistogramWrite8-4 100000 10701 ns/op 7168 B/op 296 allocs/op NEW: BenchmarkHistogramWithLabelValues-4 10000000 191 ns/op 0 B/op 0 allocs/op BenchmarkHistogramNoLabels-4 30000000 50.1 ns/op 0 B/op 0 allocs/op BenchmarkHistogramObserve1-4 30000000 40.0 ns/op 0 B/op 0 allocs/op BenchmarkHistogramObserve2-4 20000000 91.5 ns/op 0 B/op 0 allocs/op BenchmarkHistogramObserve4-4 5000000 317 ns/op 0 B/op 0 allocs/op BenchmarkHistogramObserve8-4 2000000 636 ns/op 0 B/op 0 allocs/op BenchmarkHistogramWrite1-4 1000000 2072 ns/op 896 B/op 37 allocs/op BenchmarkHistogramWrite2-4 300000 3729 ns/op 1792 B/op 74 allocs/op BenchmarkHistogramWrite4-4 200000 7847 ns/op 3584 B/op 148 allocs/op BenchmarkHistogramWrite8-4 100000 16975 ns/op 7168 B/op 296 allocs/op Signed-off-by: beorn7 <beorn@soundcloud.com> |
||
---|---|---|
.. | ||
graphite | ||
internal | ||
promauto | ||
promhttp | ||
push | ||
testutil | ||
.gitignore | ||
README.md | ||
benchmark_test.go | ||
collector.go | ||
collector_test.go | ||
counter.go | ||
counter_test.go | ||
desc.go | ||
desc_test.go | ||
doc.go | ||
example_clustermanager_test.go | ||
example_timer_complex_test.go | ||
example_timer_gauge_test.go | ||
example_timer_test.go | ||
examples_test.go | ||
expvar_collector.go | ||
expvar_collector_test.go | ||
fnv.go | ||
gauge.go | ||
gauge_test.go | ||
go_collector.go | ||
go_collector_test.go | ||
histogram.go | ||
histogram_test.go | ||
http.go | ||
http_test.go | ||
labels.go | ||
metric.go | ||
metric_test.go | ||
observer.go | ||
process_collector.go | ||
process_collector_test.go | ||
registry.go | ||
registry_test.go | ||
summary.go | ||
summary_test.go | ||
timer.go | ||
timer_test.go | ||
untyped.go | ||
value.go | ||
value_test.go | ||
vec.go | ||
vec_test.go |