JDK-8229022 : BufferedReader performance can be improved by using StringBuilder
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 8,11,14
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-07-28
  • Updated: 2022-06-27
  • Resolved: 2019-10-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 11 JDK 13 JDK 14 JDK 8 Other
11.0.6Fixed 13.0.4Fixed 14 b17Fixed 8u251Fixed openjdk8u252Fixed
Description
ADDITIONAL SYSTEM INFORMATION :
Java 11

A DESCRIPTION OF THE PROBLEM :
See https://lemire.me/blog/2019/07/26/how-fast-can-a-bufferedreader-read-lines-in-java/

BufferedReader uses StringBuffer. Swapping that to use StringBuilder seems to give a ~13% performance boost.



Comments
Fix Request (13u) Same rationale as 11u and 8u, the same patching issues. 13u RFR (reviewed by yan): https://mail.openjdk.java.net/pipermail/jdk-updates-dev/2020-May/003140.html
22-05-2020

Fix Request (8u) Same rationale as 11u. Patch does not apply cleanly to 8u due to context changes. 8u RFR (reviewed by zgu): https://mail.openjdk.java.net/pipermail/jdk8u-dev/2020-February/011245.html
20-02-2020

Fix Request (11u) This is a tiny RFE that does substantial performance improvement. Patch does not apply cleanly to 11u due to context changes. 11u RFR: https://mail.openjdk.java.net/pipermail/jdk-updates-dev/2019-October/001985.html
04-10-2019

This optimization for a common path case is trivial, so we would consider it for backports to 8 and 11.
03-10-2019

URL: https://hg.openjdk.java.net/jdk/jdk/rev/ed0058d06107 User: bpb Date: 2019-10-02 15:35:33 +0000
02-10-2019