run_stats_types.h
run_stats_types 包含了几个统计latency重要的类
one_sec_cmd_stats
shard_connection.cpp send a set command
class run_stats
run_stats.h
Important members:
one_second_stats m_cur_stats; // current second stats (appended to m_stats and reset every second)
totals m_totals; // the final statistics of latency
instantaneous command stats (used in the per second latencies)
inst_m_get_latency_histogram;
How to record the latency for each request?
Each client has a proteced member call m_stats which is an instance of class run_stats.
In the handle_response function at Client.cpp, the client calls the update_set_op funcion of m_stats to collect the latency for a request (Line 391).
接博客末尾 Memtiter-benchmark源码解析2–shard_connection
At client.cpp
At Line 393, we can see that the latency of a request is equal to the difference between a request’s sent time and its reponse’s recieved time.
client invokes the update_set_op funcion of a run_stats.
Then a run_stats calls the corresponding functions to record the latency.
Finally, we call the global hdr_record_value funcion in hdr_historgram.h to record the latency for each request at Line 190.