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

Intern strings in BlockLocation and ExtendedBlock

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.9.0, 3.0.0-alpha4
    • Component/s: None
    • Labels:
      None

      Description

      I am working on Hive performance, investigating the problem of high memory pressure when (a) a table consists of a high number (thousands) of partitions and (b) multiple queries run against it concurrently. It turns out that a lot of memory is wasted due to data duplication. One source of duplicate strings is class org.apache.hadoop.fs.BlockLocation. Its fields such as storageIds, topologyPaths, hosts, names, may collectively use up to 6% of memory in my benchmark, causing (together with other problematic classes) a huge memory spike. Of these 6% of memory taken by BlockLocation strings, more than 5% are wasted due to duplication.

      I think we need to add calls to String.intern() in the BlockLocation constructor, like:

      this.hosts = internStringsInArray(hosts);
      ...
      
      private void internStringsInArray(String[] sar) {
        for (int i = 0; i < sar.length; i++) {
          sar[i] = sar[i].intern();
        }
      }
      

      String.intern() performs very well starting from JDK 7. I've found some articles explaining the progress that was made by the HotSpot JVM developers in this area, verified that with benchmarks myself, and finally added quite a bit of interning to one of the Cloudera products without any issues.

        Attachments

        1. HDFS-11383.01.patch
          6 kB
          Misha Dmitriev
        2. hs2-crash-2.txt
          57 kB
          Misha Dmitriev
        3. HDFS-11383.02.patch
          7 kB
          Misha Dmitriev
        4. HDFS-11383.03.patch
          7 kB
          Misha Dmitriev
        5. HDFS-11383.04.patch
          8 kB
          Misha Dmitriev

          Activity

            People

            • Assignee:
              misha@cloudera.com Misha Dmitriev
              Reporter:
              misha@cloudera.com Misha Dmitriev
            • Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: