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

Suspect wrong way to calculate container utilized vcore.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Invalid
    • Affects Version/s: 2.9.1
    • Fix Version/s: None
    • Component/s: nodemanager
    • Labels:
      None

      Description

      In hadoop 2.9.1 class ContainersMonitorImpl line 664, I suspect it use the wrong way to calculate the milliVcoresUsed, below is the code.

      ResourceCalculatorProcessTree pTree = ptInfo.getProcessTree();
      pTree.updateProcessTree();    // update process-tree
      if (!pTree.isValidData()) {
        // If we cannot get the data for one container, we ignore it all
        LOG.error("Cannot get the data for " + pId);
        trackedContainersUtilization = null;
        continue;
      }
      long currentVmemUsage = pTree.getVirtualMemorySize();
      long currentPmemUsage = pTree.getRssMemorySize();
      
      // if machine has 6 cores and 3 are used,
      // cpuUsagePercentPerCore should be 300% and
      // cpuUsageTotalCoresPercentage should be 50%
      float cpuUsagePercentPerCore = pTree.getCpuUsagePercent();
      if (cpuUsagePercentPerCore < 0) {
        // CPU usage is not available likely because the container just
        // started. Let us skip this turn and consider this container
        // in the next iteration.
        LOG.info("Skipping monitoring container " + containerId
            + " since CPU usage is not yet available.");
        continue;
      }
      
      float cpuUsageTotalCoresPercentage = cpuUsagePercentPerCore /
          resourceCalculatorPlugin.getNumProcessors();
      
      // Multiply by 1000 to avoid losing data when converting to int
      int milliVcoresUsed = (int) (cpuUsageTotalCoresPercentage * 1000
          * maxVCoresAllottedForContainers /nodeCpuPercentageForYARN);
      
      // milliPcoresUsed = (int) (cpuUsagePercentPerCore * 1000 / 100;
      // As cpuUsagePercentagePerCore use 100 to represent 1 single core.
      int milliPcoresUsed = (int) (cpuUsagePercentPerCore * 10);
      // as processes begin with an age 1, we want to see if there
      // are processes more than 1 iteration old.
      vcoresUsageByAllContainers += milliVcoresUsed;
      pcoresByAllContainers += milliPcoresUsed;
      

       

      I think

       

      int milliVcoresUsed = (int) (cpuUsageTotalCoresPercentage * 1000 * maxVCoresAllottedForContainers /nodeCpuPercentageForYARN);

       

      should be 

       

      int milliVcoresUsed = (int) (cpuUsageTotalCoresPercentage * 1000 * maxVCoresAllottedForContainers;
      

       

       

      I think it need not to divide nodeCpuPercentageForYARN, Karthik Kambatla, looks you add this feature, could you help to have a look ? or could you educate me if I am wrong ?

       

       

       

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              sihai Sihai Ke
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: