Skip to content

Commit

Permalink
stopwatch: ensure LOG_TIMING always prints
Browse files Browse the repository at this point in the history
On rare occasion in benchmark runs, the LOG_TIMING macro doesn't produce
any output. It's not entirely clear why this happens, but it seems the
only possibility is that the so-called monotonic clock is going
backwards. This change ensures that the macro always prints even if the
clock moves backwards.

Change-Id: I67fe658801be153cbcb6efb31cc8f3bf9eaf944f
Reviewed-on: http://gerrit.cloudera.org:8080/7333
Tested-by: Kudu Jenkins
Reviewed-by: Adar Dembo <[email protected]>
  • Loading branch information
toddlipcon committed Jun 30, 2017
1 parent b33689e commit 41a3aea
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/kudu/util/stopwatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,10 @@ class LogTiming {
void Print(int64_t max_expected_millis) {
stopwatch_.stop();
CpuTimes times = stopwatch_.elapsed();
if (times.wall_millis() > max_expected_millis) {
// TODO(todd): for some reason, times.wall_millis() sometimes ends up negative
// on rare occasion, for unclear reasons, so we have to check max_expected_millis
// < 0 to be sure we always print when requested.
if (max_expected_millis < 0 || times.wall_millis() > max_expected_millis) {
google::LogMessage(file_, line_, severity_).stream()
<< prefix_ << "Time spent " << description_ << ": "
<< times.ToString();
Expand Down

0 comments on commit 41a3aea

Please sign in to comment.