Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-11047

Remove deep copies of FinalizedReplica to alleviate heap consumption on DataNode

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.8.0, 3.0.0-alpha2
    • Component/s: datanode
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      DirectoryScanner does scan by deep copying FinalizedReplica. In a deployment with 500,000+ blocks, we've seen the DN heap usage being accumulated to high peaks very quickly. Deep copies of FinalizedReplica will make DN heap usage even worse if directory scans are scheduled more frequently. This proposes removing unnecessary deep copies since DirectoryScanner#scan already holds lock of dataset.

      DirectoryScanner#scan

          try(AutoCloseableLock lock = dataset.acquireDatasetLock()) {
            for (Entry<String, ScanInfo[]> entry : diskReport.entrySet()) {
              String bpid = entry.getKey();
              ScanInfo[] blockpoolReport = entry.getValue();
              
              Stats statsRecord = new Stats(bpid);
              stats.put(bpid, statsRecord);
              LinkedList<ScanInfo> diffRecord = new LinkedList<ScanInfo>();
              diffs.put(bpid, diffRecord);
              
              statsRecord.totalBlocks = blockpoolReport.length;
              List<ReplicaInfo> bl = dataset.getFinalizedBlocks(bpid); /* deep copies here*/
      

      FsDatasetImpl#getFinalizedBlocks

        public List<ReplicaInfo> getFinalizedBlocks(String bpid) {
          try (AutoCloseableLock lock = datasetLock.acquire()) {
            ArrayList<ReplicaInfo> finalized =
                new ArrayList<ReplicaInfo>(volumeMap.size(bpid));
            for (ReplicaInfo b : volumeMap.replicas(bpid)) {
              if (b.getState() == ReplicaState.FINALIZED) {
                finalized.add(new ReplicaBuilder(ReplicaState.FINALIZED)
                    .from(b).build()); /* deep copies here*/
              }
            }
            return finalized;
          }
        }
      

        Attachments

        1. HDFS-11047.000.patch
          7 kB
          Xiaobing Zhou
        2. HDFS-11047.001.patch
          5 kB
          Xiaobing Zhou
        3. HDFS-11047.002.patch
          5 kB
          Xiaobing Zhou
        4. HDFS-11047-branch-2.002.patch
          5 kB
          Xiaobing Zhou

          Activity

            People

            • Assignee:
              xiaobingo Xiaobing Zhou
              Reporter:
              xiaobingo Xiaobing Zhou
            • Votes:
              0 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: