JDK-8176894 : Provide specialized implementation for default methods putIfAbsent, computeIfAbsent, computeIfPresent, compute, merge in TreeMap
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util:collections
  • Affected Version: 10
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2017-03-16
  • Updated: 2021-01-11
  • Resolved: 2020-04-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 15
15 b18Fixed
Related Reports
CSR :  
Relates :  
Relates :  
Sub Tasks
JDK-8250842 :  
Description
TreeMap doesn't have specialized implementation for methods putIfAbsent(), computeIfAbsent(), computeIfPresent(), compute(). Default implementation frequently leads to twice tree traversal, that hurts performance.

Implementation: http://cr.openjdk.java.net/~skuksenko/corelibs/utils/8176894/webrev.00/

Suggested implementation improve performance of all 4 operations within 40%-100% (than higher cost of compare operation than more performance boost).

Note: some of these operations are used in new HttpClient (JEP-110, jdk.incubator.httpclient). Performance speedup for HTTP/2 requests are within 5%-15% (depends on size of HTTP headers)

Comments
Same issue but it might be that maven-bundle-plugin have released with an updated dependency.
26-06-2020

Hmm... I see issues with maven-bundle-plugin ( when building Jackson ). Is this a duplicate of the above, or a new and separate issue ( will report it to maven-bundle-plugin if it is ) INFO] [INFO] --- jacoco-maven-plugin:0.8.5:report (report) @ jackson-annotations --- [INFO] Loading execution data file /Users/chhegar/git/jackson-annotations/target/jacoco.exec [INFO] Analyzed bundle 'Jackson-annotations' with 29 classes [INFO] [INFO] --- maven-bundle-plugin:4.2.0:bundle (default-bundle) @ jackson-annotations --- [ERROR] An internal error occurred java.util.ConcurrentModificationException at java.base/java.util.TreeMap.callMappingFunctionWithCheck(TreeMap.java:742) at java.base/java.util.TreeMap.computeIfAbsent(TreeMap.java:596) at aQute.bnd.osgi.Jar.putResource(Jar.java:288) at aQute.bnd.osgi.Jar$1.visitFile(Jar.java:202) at aQute.bnd.osgi.Jar$1.visitFile(Jar.java:177) at java.base/java.nio.file.Files.walkFileTree(Files.java:2804) at aQute.bnd.osgi.Jar.buildFromDirectory(Jar.java:176) at aQute.bnd.osgi.Jar.<init>(Jar.java:119) at aQute.bnd.osgi.Jar.<init>(Jar.java:172) at org.apache.felix.bundleplugin.BundlePlugin.getOSGiBuilder(BundlePlugin.java:603) at org.apache.felix.bundleplugin.BundlePlugin.buildOSGiBundle(BundlePlugin.java:934) at org.apache.felix.bundleplugin.BundlePlugin.execute(BundlePlugin.java:443) at org.apache.felix.bundleplugin.BundlePlugin.execute(BundlePlugin.java:364) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214) at org.apache.maven.cli.MavenCli.main(MavenCli.java:158) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------
26-06-2020

The changes here means that CME will be throw for usages that were not detected previously, e.g: https://github.com/bndtools/bnd/issues/3903 I've added release-notes=yes to this issue to remind us to add a release note for this change.
26-06-2020

URL: https://hg.openjdk.java.net/jdk/jdk/rev/65b345254ca3 User: tvaleev Date: 2020-04-02 05:44:55 +0000
02-04-2020

I realized that if we don't check modCount after calling mapping function we may get corrupted tree structure. new webrev for review: http://cr.openjdk.java.net/~skuksenko/corelibs/utils/8176894/webrev.01/
18-03-2017