Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-3398

ReduceTask::closestPowerOf2 is inefficient

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • None
    • 0.18.0
    • None
    • None
    • Reviewed

    Description

      ReduceTask computes the "closest power of 2" using loops

      private static int getClosestPowerOf2(int value) {
        int power = 0;
        int approx = 1;
        while (approx < value) {
          ++power;
          approx = (approx << 1);
        }
        if ((value - (approx >> 1)) < (approx - value)) {
          --power;
        }
        return power;
      }
      

      This could be improved.

      Attachments

        1. 3398-3.patch
          1 kB
          Christopher Douglas
        2. 3398-2.patch
          1 kB
          Christopher Douglas
        3. 3398-1.patch
          0.7 kB
          Christopher Douglas
        4. 3398-0.patch
          0.7 kB
          Christopher Douglas

        Activity

          People

            cdouglas Christopher Douglas
            cdouglas Christopher Douglas
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: