Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-17331

Avoid busy waiting in ThrottledInputStream

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.0.0
    • 2.0.0
    • None
    • None
    • Reviewed
    • For each read(), old ThrottledInputStream sleeps/wakes/checks for many times for controlling the throughput. After this patch, ThrottledInputStream sleeps/wakes/checks only once. So we can reduce CPU usage.

    Description

      ThrottledInputStream.java
      // We can calculate the precise sleep time instead of busy waiting
        private void throttle() throws IOException {
          while (getBytesPerSec() > maxBytesPerSec) {
            try {
              Thread.sleep(SLEEP_DURATION_MS);
              totalSleepTime += SLEEP_DURATION_MS;
            } catch (InterruptedException e) {
              throw new IOException("Thread aborted", e);
            }
          }
        }
      

      Attachments

        1. HBASE-17331.v2.patch
          6 kB
          Chia-Ping Tsai
        2. HBASE-17331.v2.patch
          6 kB
          Chia-Ping Tsai
        3. HBASE-17331.v1.patch
          6 kB
          Chia-Ping Tsai
        4. HBASE-17331.v0.patch
          5 kB
          Chia-Ping Tsai
        5. HBASE-17331.addendum.patch
          3 kB
          Chia-Ping Tsai

        Activity

          People

            chia7712 Chia-Ping Tsai
            chia7712 Chia-Ping Tsai
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: