Uploaded image for project: 'Ranger'
  1. Ranger
  2. RANGER-3386

apache CollectionUtils package reduce ranger agent performance and should be replaced

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Patch Available
    • Major
    • Resolution: Unresolved
    • 2.0.1
    • None
    • plugins
    • None

    Description

      org.apache.commons.collections.CollectionUtils' performance is too poor and reduce the performance of ranger plugins, particularly with hdfs. There are too many places used CollectionUtils.isNotEmpty and CollectionUtils.isEmpty in agent component, so we should replace them.

      We can see many CollectionUtils call is take too much time in namenode benchmark's result.

      In this patch, I replace almost CollectionUtils functions in agents-common. After adding this patch, in creating file benchmark of hdfs, the performance can improve from creating 7000 files to 7600 files per second.

      By the way, I write a simple test code below. collection.isEmpty is almost take 0 milliseconds, but CollectionUtils.isNotEmpty take 5 milliseconds.

       

      List<Integer> list = new ArrayList<Integer>();
      for(int i = 0; i<1000; i++)
          list.add(i);
      
      long startTime = System.currentTimeMillis();
      if(list != null && !list.isEmpty()){
      
      }
      long endTime   = System.currentTimeMillis();
      long totalTime = endTime - startTime;
      System.out.println(totalTime);
      
      
      long startTime2 = System.currentTimeMillis();
      CollectionUtils.isNotEmpty(list);
      long endTime2   = System.currentTimeMillis();
      long totalTime2 = endTime2 - startTime2;
      System.out.println(totalTime2);
      

       

      Attachments

        1. RANGER-3386-branch-2.0.1.001.patch
          176 kB
          caozhiqiang
        2. CollectionUtils.png
          889 kB
          caozhiqiang
        3. RANGER-3386-branch-2.0.1.002.patch
          176 kB
          caozhiqiang

        Issue Links

          Activity

            People

              caozhiqiang caozhiqiang
              caozhiqiang caozhiqiang
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: