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

Avoid ConcurrentHashMap resizes during bootstrap

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 14
    • Component/s: core-libs
    • Subcomponent:
    • Resolved In Build:
      b10

      Description

      Analysis shows that a handful of small ConcurrentHashMaps used during bootstrap is subject to some amount of resizing. Initializing these to slightly larger values improves startup metrics measurably on default images without regressing performance on minimal images.

      diff -r 05ff6e27de45 src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java
      --- a/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java Mon Aug 12 10:02:25 2019 +0200
      +++ b/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java Mon Aug 12 12:04:34 2019 +0200
      @@ -183,7 +183,7 @@
               this.parent = parent;
               this.ucp = ucp;
       
      - this.nameToModule = new ConcurrentHashMap<>();
      + this.nameToModule = new ConcurrentHashMap<>(32);
               this.moduleToReader = new ConcurrentHashMap<>();
           }
       
      diff -r 05ff6e27de45 src/java.base/share/classes/jdk/internal/module/ServicesCatalog.java
      --- a/src/java.base/share/classes/jdk/internal/module/ServicesCatalog.java Mon Aug 12 10:02:25 2019 +0200
      +++ b/src/java.base/share/classes/jdk/internal/module/ServicesCatalog.java Mon Aug 12 12:04:34 2019 +0200
      @@ -81,7 +81,7 @@
           }
       
           // service name -> list of providers
      - private final Map<String, List<ServiceProvider>> map = new ConcurrentHashMap<>();
      + private final Map<String, List<ServiceProvider>> map = new ConcurrentHashMap<>(32);
       
           private ServicesCatalog() { }
       

        Attachments

          Activity

            People

            Assignee:
            redestad Claes Redestad
            Reporter:
            redestad Claes Redestad
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: