Fix trace_analyzer potential huge memory wasting due to no valid query analyzed (#4473)

Summary:
If the query types being analyzed do not appear in the trace, the current trace_analyzer will use 0 as the begin time, which create the time duration from 1970/01/01 to the now time. It will waste huge memory. Fixed by adding the trace_create_time to limit the duration.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4473

Differential Revision: D10246204

Pulled By: zhichao-cao

fbshipit-source-id: 42850b080b2e62f586fe73afd7737c2246d1a8c8
main
Zhichao Cao 6 years ago committed by Facebook Github Bot
parent 854a4be03f
commit 7ca1a1f0d8
  1. 5
      tools/trace_analyzer_tool.cc
  2. 1
      tools/trace_analyzer_tool.h

@ -276,6 +276,7 @@ TraceAnalyzer::TraceAnalyzer(std::string& trace_path, std::string& output_path,
total_access_keys_ = 0; total_access_keys_ = 0;
total_gets_ = 0; total_gets_ = 0;
total_writes_ = 0; total_writes_ = 0;
trace_create_time_ = 0;
begin_time_ = 0; begin_time_ = 0;
end_time_ = 0; end_time_ = 0;
time_series_start_ = 0; time_series_start_ = 0;
@ -422,6 +423,7 @@ Status TraceAnalyzer::StartProcessing() {
fprintf(stderr, "Cannot read the header\n"); fprintf(stderr, "Cannot read the header\n");
return s; return s;
} }
trace_create_time_ = header.ts;
if (FLAGS_output_time_series) { if (FLAGS_output_time_series) {
time_series_start_ = header.ts; time_series_start_ = header.ts;
} }
@ -740,6 +742,9 @@ Status TraceAnalyzer::MakeStatisticCorrelation(TraceStats& stats,
// Process the statistics of QPS // Process the statistics of QPS
Status TraceAnalyzer::MakeStatisticQPS() { Status TraceAnalyzer::MakeStatisticQPS() {
if(begin_time_ == 0) {
begin_time_ = trace_create_time_;
}
uint32_t duration = uint32_t duration =
static_cast<uint32_t>((end_time_ - begin_time_) / 1000000); static_cast<uint32_t>((end_time_ - begin_time_) / 1000000);
int ret; int ret;

@ -204,6 +204,7 @@ class TraceAnalyzer {
uint64_t total_access_keys_; uint64_t total_access_keys_;
uint64_t total_gets_; uint64_t total_gets_;
uint64_t total_writes_; uint64_t total_writes_;
uint64_t trace_create_time_;
uint64_t begin_time_; uint64_t begin_time_;
uint64_t end_time_; uint64_t end_time_;
uint64_t time_series_start_; uint64_t time_series_start_;

Loading…
Cancel
Save