Uploaded image for project: 'Hadoop YARN'
  1. Hadoop YARN
  2. YARN-6870

Fix floating point inaccuracies in resource availability check in AllocationBasedResourceUtilizationTracker

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.9.0, 3.0.0-beta1
    • api, nodemanager
    • None

    Description

      We have seen issues on our clusters where the current way of computing CPU usage is having float-arithmetic inaccuracies (the bug is still there in trunk)

      Simple program to illustrate:

      Bar.java
            public static void main(String[] args) throws Exception {
                  float result = 0.0f;
                  for (int i = 0; i < 7; i++) {
                        if (i == 6) {
                              result += (float) 4 / (float)18;
                        } else {
                              result += (float) 2 / (float)18;
                        }
                  }
                  for (int i = 0; i < 7; i++) {
                        if (i == 6) {
                              result -= (float) 4 / (float)18;
                        } else {
                              result -= (float) 2 / (float)18;
                        }                 
                  }
                  System.out.println(result);
            }
      

      // Printed
      4.4703484E-8

      2017-04-12 05:43:24,014 INFO org.apache.hadoop.yarn.server.nodemanager.containermanager.monitor.ContainersMonitorImpl: Not enough cpu for [container_e3295_1491978508342_0467_01_000030], Current CPU Allocation: [0.8888891], Requested CPU Allocation: [0.11111111]

      There are a few places with this issue:
      1. ResourceUtilization.java - set/getCPU both use float. When ContainerScheduler calls ContainersMonitor.increase/decreaseResourceUtilization, this may lead to issues.

      2. AllocationBasedResourceUtilizationTracker.java - hasResourcesAvailable uses float as well for CPU computation.

      Attachments

        1. YARN-6870-v3.patch
          9 kB
          Brook Zhou
        2. YARN-6870-v2.patch
          9 kB
          Brook Zhou
        3. YARN-6870-v1.patch
          9 kB
          Brook Zhou
        4. YARN-6870-v0.patch
          8 kB
          Brook Zhou

        Activity

          People

            brookz Brook Zhou
            brookz Brook Zhou
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: