JDK-8221733 : Basic string concatenation performance has got significantly worse in Java 11
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 11,12,13
  • Priority: P3
  • Status: Resolved
  • Resolution: Not an Issue
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2019-03-28
  • Updated: 2019-06-17
  • Resolved: 2019-06-17
Related Reports
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
I have tested it on various versions of Window and got the same results. I have not tried any other OS.

A DESCRIPTION OF THE PROBLEM :
Basic string concatenation performance has got significantly worse in Java 11 compared to Java 8. I wrote some very basic test code and posted on Stack Overflow to see what other developers thought and they confirmed similar results.

https://stackoverflow.com/questions/55395958/java-11-string-concatenation-performance-vs-java-8

REGRESSION : Last worked in version 8u192

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the code in the above link under Java 8 and Java 11.

https://stackoverflow.com/questions/55395958/java-11-string-concatenation-performance-vs-java-8


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The code will take noticably longer to run under Java 11 versus Java 8.
ACTUAL -
The code takes noticably longer to run under Java 11 versus Java 8.

---------- BEGIN SOURCE ----------
https://stackoverflow.com/questions/55395958/java-11-string-concatenation-performance-vs-java-8

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
I have not been able to find any runtime flags or alternative string concatenation packages that give me a comparable performance to Java 8.

FREQUENCY : always



Comments
Thanks for getting to the bottom of this, Aleksey. Now that we have JDK-8221760, I'll close this issue.
17-06-2019

While this one seems not be the the issue on for the code that runs on both 8u and 11u, there looks to be the 11u regression on more extensive test, tracked by JDK-8221760.
01-04-2019

I think the observed behavior is due to G1 by default: https://stackoverflow.com/a/55457533/2613885, on top of usual benchmarking pitfalls.
01-04-2019

not sure if regression in 9 is related to JDK-8085796 or not.
01-04-2019

To reproduce the issue, run the attached test case provided in the stackoverflow link of the bug description. Following are the results on Windows Server 2016: JDK 8u201 : Starting performance test initial block took 3651ms Main block took 10849ms JDK-9 GA: Starting performance test initial block took 4709ms Main block took 16082ms JDK-11.0.2: Starting performance test initial block took 4953ms Main block took 17307ms JDK-12 GA: Starting performance test initial block took 5054ms Main block took 17475ms JDK-13ea+14: Starting performance test initial block took 5259ms Main block took 17438ms
01-04-2019