Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-2312

Timing bug in both MonotonicStopWatch and StopWatch

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • Impala 2.2.4
    • Impala 3.4.0
    • Backend
    • None

    Description

      Both MonotonicStopWatch and StopWatch underestimate the total time if the stopwatch is running while ElapsedTime() is called. For example:

      uint64_t ElapsedTime() const {
          if (!running_) return total_time_;
          timespec end;
          clock_gettime(CLOCK_MONOTONIC, &end);
          // Should include total_time_, but does not
          return (end.tv_sec - start_.tv_sec) * 1000L * 1000L * 1000L +
              (end.tv_nsec - start_.tv_nsec);
        }
      

      The effect is that we could have:

      MonotonicStopWatch sw;
      sw.Start();
      sw.Stop();
      uint64_t total = sw.ElapsedTime();
      sw.Start();
      // With the bug, this could fail.
      ASSERT_GE(sw.ElapsedTime(), total);
      

      Attachments

        Activity

          People

            tarmstrong Tim Armstrong
            henryr Henry Robinson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: