client_golang/prometheus
beorn7 1b2bd1d665 Make Histogram observations atomic while keeping them lock-free
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>
2018-09-12 15:03:44 +02:00
..
graphite Add missing license headers 2018-08-22 13:53:56 +02:00
internal Create an internal package 2018-09-03 00:18:11 +02:00
promauto promauto: add NewCounterFunc and NewGaugeFunc 2018-03-17 14:01:36 -07:00
promhttp forgot some &s 2018-07-13 09:28:19 -04:00
push Fix typos 2018-04-13 23:23:52 +02:00
testutil Add package documentation 2018-09-04 14:02:20 +02:00
.gitignore Rearrange file and package per convention. 2013-04-04 15:27:09 +02:00
README.md Create a public registry interface and separate out HTTP exposition 2016-08-02 18:46:22 +02:00
benchmark_test.go Add a benchmark for concurrent counter increments 2018-01-19 15:15:10 -08:00
collector.go Add a DescribeByCollect helper 2018-09-05 14:10:51 +02:00
collector_test.go Add a DescribeByCollect helper 2018-09-05 14:10:51 +02:00
counter.go Iterate on a proposed performance improvement for counters 2018-01-19 19:06:43 +01:00
counter_test.go Iterate on a proposed performance improvement for counters 2018-01-19 19:06:43 +01:00
desc.go Un-export prometheus.LabelPairSorter 2018-09-03 16:20:55 +02:00
desc_test.go Add missing license headers 2018-08-22 13:53:56 +02:00
doc.go Introduce unchecked Collectors 2018-07-09 14:33:18 +02:00
example_clustermanager_test.go Fix a number of doc comments and similar nits 2016-08-03 12:23:37 +02:00
example_timer_complex_test.go fix spelling typo 2017-08-28 08:57:51 +08:00
example_timer_gauge_test.go Fix invalid Timer (gauge) example 2017-02-28 11:13:17 -04:00
example_timer_test.go Change the Timer API 2016-11-18 20:32:18 +01:00
examples_test.go Un-export prometheus.LabelPairSorter 2018-09-03 16:20:55 +02:00
expvar_collector.go Create a public registry interface and separate out HTTP exposition 2016-08-02 18:46:22 +02:00
expvar_collector_test.go Simplify if expr in ExampleNewExpvarCollector() 2018-04-13 23:23:52 +02:00
fnv.go Add missing license headers 2018-08-22 13:53:56 +02:00
gauge.go Iterate on a proposed performance improvement for counters 2018-01-19 19:06:43 +01:00
gauge_test.go Iterate on a proposed performance improvement for counters 2018-01-19 19:06:43 +01:00
go_collector.go Add missing license headers 2018-08-22 13:53:56 +02:00
go_collector_test.go Add missing license headers 2018-08-22 13:53:56 +02:00
histogram.go Make Histogram observations atomic while keeping them lock-free 2018-09-12 15:03:44 +02:00
histogram_test.go Make Histogram observations atomic while keeping them lock-free 2018-09-12 15:03:44 +02:00
http.go go routine to goroutine 2018-08-07 21:23:58 +02:00
http_test.go Fix three shadow variable warnings (govet -shadow) 2018-04-13 23:25:14 +02:00
labels.go Add missing license headers 2018-08-22 13:53:56 +02:00
metric.go Un-export prometheus.LabelPairSorter 2018-09-03 16:20:55 +02:00
metric_test.go Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00
observer.go Pull currying methods up into ObserverVec interface 2017-12-22 16:11:58 +01:00
process_collector.go Rework process collector 2018-09-07 12:09:26 +02:00
process_collector_test.go Rework process collector 2018-09-07 12:09:26 +02:00
registry.go Rework process collector 2018-09-07 12:09:26 +02:00
registry_test.go Add suffix collision checks during gathering 2018-07-13 16:29:17 +02:00
summary.go typo 2018-08-27 12:01:30 -04:00
summary_test.go Check quantile label during SummaryVec construction 2018-07-13 13:43:21 +02:00
timer.go Document the use of Go1.9+ for monotonic time where applicable 2017-06-29 16:07:12 +02:00
timer_test.go new handler instrumentation (#285) 2017-04-24 15:13:19 -04:00
untyped.go Remove the deprecated uses of Untyped metrics 2017-08-29 17:31:45 +02:00
value.go Un-export prometheus.LabelPairSorter 2018-09-03 16:20:55 +02:00
value_test.go Add missing license headers 2018-08-22 13:53:56 +02:00
vec.go Fix unprotected write in metricMap 2018-04-09 10:10:15 -04:00
vec_test.go Allow currying of metric vec's 2017-12-22 15:56:11 +01:00

README.md

See go-doc.