Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8208077

File.listRoots performance degradation (from fix for JDK-8182710)

    Details

    • Subcomponent:
    • Introduced In Build:
      b14
    • Introduced In Version:
      10
    • CPU:
      x86_64
    • OS:
      windows_10

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Windows

      A DESCRIPTION OF THE PROBLEM :
      listRoots used to return right away, (1 call takes <1ms), now (when the system has a CD/DVD drive), it takes 0.125 SECONDs to return. -When the system does not have a CD/DVD drive, it still take 25 ms to return.

      This looks to be a regression from bug fix for 8182710: File.listRoots() always returns the root of CD drive.
      Looks the fix after getting the listRoots0 further incurred some System calls, which added quite a bit of cost to the listRoots.

      REGRESSION : Last worked in version 8u172

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the attached java source code with jdk 1.7 or 1.8, run it with command "java TestFileListRoots", it returns right away (0 ms). switch java to 9 (I used 9.0.4), do command "java TestFileListRoots", it still returns right away (0 ms). Now switch to use java 10 (I used 10.0.1), it took 0.125 seconds to return. Switch to java 11 (11-ea-15), similar bad performance.

      ACTUAL -
      C:\fzhou4_c2>java -version
      java version "1.7.0_80"
      Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
      Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

      C:\fzhou4_c2>javac TestFileListRoots.java

      C:\fzhou4_c2>java TestFileListRoots
      Took 0.0 seconds
      Here are the root paths:
      C:\
      D:\
      E:\
      S:\
      Z:\

      C:\fzhou4_c2>set JAVA_HOME=C:\fzhou4_c2\3rd_Party\jsdk\9.0.4\Windows

      C:\fzhou4_c2>set PATH=C:\fzhou4_c2\3rd_Party\jsdk\9.0.4\Windows\bin

      C:\fzhou4_c2>java TestFileListRoots
      Took 0.0 seconds
      Here are the root paths:
      C:\
      D:\
      E:\
      S:\
      Z:\

      C:\fzhou4_c2>set JAVA_HOME=C:\fzhou4_c2\3rd_Party\jsdk\10.0.1\Windows

      C:\fzhou4_c2>set PATH=C:\fzhou4_c2\3rd_Party\jsdk\10.0.1\Windows\bin

      C:\fzhou4_c2>java -version
      java version "10.0.1" 2018-04-17
      Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
      Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)

      C:\fzhou4_c2>java TestFileListRoots
      Took 0.125 seconds
      Here are the root paths:
      C:\
      D:\
      S:\
      Z:\

      C:\fzhou4_c2>set JAVA_HOME=C:\fzhou4_c2\3rd_Party\jsdk\11.ea.15\Windows

      C:\fzhou4_c2>set PATH=C:\fzhou4_c2\3rd_Party\jsdk\11.ea.15\Windows\bin

      C:\fzhou4_c2>java -version
      java version "11-ea" 2018-09-25
      Java(TM) SE Runtime Environment 18.9 (build 11-ea+15)
      Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11-ea+15, mixed mode)

      C:\fzhou4_c2>java TestFileListRoots
      Took 0.125 seconds
      Here are the root paths:
      C:\
      D:\
      S:\
      Z:\


      ---------- BEGIN SOURCE ----------
      import java.io.File;

      public class TestFileListRoots {
      public static void main(String[] args) {
      long start = System.currentTimeMillis();
      int fileCount = 0;
      File[] files = File.listRoots();
      fileCount = files.length;
      String[] rootPaths = new String[fileCount];
      int index = 0;
      for (File file : files) {
      String rootPath = file.getAbsolutePath();
      rootPaths[index++] = rootPath;
      }
      long end = System.currentTimeMillis();
      System.out.println("Took " + ((end - start)/1000.0) + " seconds");
      System.out.println("Here are the root paths:");
      for (String path : rootPaths) {
      System.out.println(path);
      }
      }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bpb Brian Burkhalter
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: