Closed empiredan closed 2 years ago
LGTM
Can you construct a benchmark for its performance compared with the origin perf_counter?
Can you construct a benchmark for its performance compared with the origin perf_counter?
Actually the benchmark given in https://github.com/apache/incubator-pegasus/issues/889 has involved the comparison with the original perf-counter: divided_long_adder
is nearly the same with the original dsn::perf_counter_number_atomic
except that its virtual functions are removed since other long adders also have no virtual function.
The implementation of divided_long_adder
can be found in src/utils/long_adder_bench/long_adder_bench.cpp
.
What's th difference between this PR's implemention and the original https://github.com/apache/kudu/blob/master/src/kudu/util/striped64.h?
What's th difference between this PR's implemention and the original https://github.com/apache/kudu/blob/master/src/kudu/util/striped64.h?
The data structures and algorithms between both striped long adder are based on striped64. The differences are:
unique_ptr<...>
to manage the memory of cells, while kudu releases memory by calling free()
in the destructor.fetch_and_reset
, since we have volatile
scenarios where only recent count will be showed.if (c)
with if (c != nullptr)
.dsn::utils::get_current_tid()
to get the initial hash code, while kudu uses Random
to get.concurrent_long_adder
to optimize the scenario that the adder is updated very frequently.long_adder_wrapper
to wrap the interfaces of long adder.
https://github.com/apache/incubator-pegasus/issues/889