Skip to content

Commit

Permalink
Fix trace_analyzer potential huge memory wasting due to no valid quer…
Browse files Browse the repository at this point in the history
…y analyzed (facebook#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: facebook#4473

Differential Revision: D10246204

Pulled By: zhichao-cao

fbshipit-source-id: 42850b080b2e62f586fe73afd7737c2246d1a8c8
  • Loading branch information
zhichao-cao authored and facebook-github-bot committed Oct 10, 2018
1 parent 854a4be commit 7ca1a1f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tools/trace_analyzer_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ TraceAnalyzer::TraceAnalyzer(std::string& trace_path, std::string& output_path,
total_access_keys_ = 0;
total_gets_ = 0;
total_writes_ = 0;
trace_create_time_ = 0;
begin_time_ = 0;
end_time_ = 0;
time_series_start_ = 0;
Expand Down Expand Up @@ -422,6 +423,7 @@ Status TraceAnalyzer::StartProcessing() {
fprintf(stderr, "Cannot read the header\n");
return s;
}
trace_create_time_ = header.ts;
if (FLAGS_output_time_series) {
time_series_start_ = header.ts;
}
Expand Down Expand Up @@ -740,6 +742,9 @@ Status TraceAnalyzer::MakeStatisticCorrelation(TraceStats& stats,

// Process the statistics of QPS
Status TraceAnalyzer::MakeStatisticQPS() {
if(begin_time_ == 0) {
begin_time_ = trace_create_time_;
}
uint32_t duration =
static_cast<uint32_t>((end_time_ - begin_time_) / 1000000);
int ret;
Expand Down
1 change: 1 addition & 0 deletions tools/trace_analyzer_tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ class TraceAnalyzer {
uint64_t total_access_keys_;
uint64_t total_gets_;
uint64_t total_writes_;
uint64_t trace_create_time_;
uint64_t begin_time_;
uint64_t end_time_;
uint64_t time_series_start_;
Expand Down

0 comments on commit 7ca1a1f

Please sign in to comment.