-
Notifications
You must be signed in to change notification settings - Fork 201
Open
Labels
Description
We need to implement a int version for Histogram, like Counter and Gauge, since atomic float implementation (loop + lock cmpxchg
) is much slower than native atomic integer instruction (lock add
).
For example, according to benchmarks:
test bench_counter_no_labels ... bench: 14 ns/iter (+/- 0)
test bench_int_counter_no_labels ... bench: 7 ns/iter (+/- 1)
When there is no concurrent write, float atomic implemented via CAS is 1x slower than int atomic.
test bench_counter_no_labels_concurrent_write ... bench: 5,263 ns/iter (+/- 1,204)
test bench_int_counter_no_labels_concurrent_write ... bench: 892 ns/iter (+/- 100)
When there is concurrent write, float atomic is 5x slower than int atomic.