Re: RFR: 8358533: Improve performance of java.io.Reader.readAllLines [v3]

2025-06-25 Thread Brian Burkhalter
On Fri, 20 Jun 2025 17:16:58 GMT, Xueming Shen wrote: >> The change is motivated by performance, but there will be many inputs that >> are less than the transfer buffer size and those will not use the >> StringBuilder, so creating it before it is needed could be avoided. >> When a partial line

Re: RFR: 8358533: Improve performance of java.io.Reader.readAllLines [v3]

2025-06-25 Thread Brian Burkhalter
On Tue, 24 Jun 2025 18:49:08 GMT, Brian Burkhalter wrote: >> resizing/newCapacity is always expensive and tricky, string builder >> included. so maybe we should decide if 'long lines' (> transfer buffer size) >> is the goal of this pr. if not, it might be reasonable/make sense (???) to >> sim

Re: RFR: 8358533: Improve performance of java.io.Reader.readAllLines [v3]

2025-06-24 Thread Brian Burkhalter
On Tue, 24 Jun 2025 08:08:58 GMT, Andrey Turbanov wrote: >> Brian Burkhalter has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8358533: Init StringBuilder to size zero; use StringBuilder.isEmpty() > > test/micro/org/openjdk/bench/java/io/R

Re: RFR: 8358533: Improve performance of java.io.Reader.readAllLines [v3]

2025-06-24 Thread Brian Burkhalter
On Mon, 23 Jun 2025 21:23:05 GMT, Stuart Marks wrote: >> src/java.base/share/classes/java/io/Reader.java line 508: >> >>> 506: } >>> 507: >>> 508: return lines; >> >> Do we really want to return a mutable `ArrayList` here? In earlier >> discussions about this very API I was to

Re: RFR: 8358533: Improve performance of java.io.Reader.readAllLines [v3]

2025-06-24 Thread Brian Burkhalter
On Tue, 24 Jun 2025 19:12:25 GMT, Roger Riggs wrote: > One possibility is to copy the remaining fragment of a line to a new transfer > buffer (maybe twice the size). It's probably worth testing this. - PR Review Comment: https://git.openjdk.org/jdk/pull/25863#discussion_r216472586

Re: RFR: 8358533: Improve performance of java.io.Reader.readAllLines [v3]

2025-06-24 Thread Brian Burkhalter
On Tue, 24 Jun 2025 18:46:49 GMT, Brian Burkhalter wrote: >> The `readAllLines` method has a specification of line terminators that >> agrees with that of `BufferedReader::readLine` and `String::lines` and so we >> don't want to change it to be different. >> >> Unfortunately `Scanner` doesn't

Re: RFR: 8358533: Improve performance of java.io.Reader.readAllLines [v3]

2025-06-24 Thread Roger Riggs
On Tue, 24 Jun 2025 19:00:42 GMT, Brian Burkhalter wrote: >>> My suggestion is to call `new StringBuilder(0)` >> >> So changed in 8ccfd54. > >> When a partial line is left in the transfer buffer, copy it to the beginning >> of the buffer and read more characters for the remaining size of the bu

Re: RFR: 8358533: Improve performance of java.io.Reader.readAllLines [v3]

2025-06-24 Thread Brian Burkhalter
On Thu, 19 Jun 2025 10:59:14 GMT, Markus KARG wrote: > Is there a reason for `sb.length() == 0` instead of `sb.isEmpty()`? The former is identical. Modified to use `isEmpty` in 8ccfd54. - PR Review Comment: https://git.openjdk.org/jdk/pull/25863#discussion_r2164686620

Re: RFR: 8358533: Improve performance of java.io.Reader.readAllLines [v3]

2025-06-24 Thread Brian Burkhalter
On Wed, 18 Jun 2025 02:12:50 GMT, Shaojin Wen wrote: >> Brian Burkhalter has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8358533: Init StringBuilder to size zero; use StringBuilder.isEmpty() > > src/java.base/share/classes/java/io/Reader

Re: RFR: 8358533: Improve performance of java.io.Reader.readAllLines [v3]

2025-06-24 Thread Brian Burkhalter
On Wed, 18 Jun 2025 02:25:03 GMT, Chen Liang wrote: >> Brian Burkhalter has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8358533: Init StringBuilder to size zero; use StringBuilder.isEmpty() > > src/java.base/share/classes/java/io/Reader.

Re: RFR: 8358533: Improve performance of java.io.Reader.readAllLines [v3]

2025-06-24 Thread Brian Burkhalter
On Mon, 23 Jun 2025 21:16:30 GMT, Stuart Marks wrote: >> `Scanner` seems to scan for even more characters: >> https://github.com/openjdk/jdk/blob/c4fb00a7be51c7a05a29d3d57d787feb5c698ddf/src/java.base/share/classes/java/util/Scanner.java#L490 >> >> Would it make sense to resemble this? Would it

Re: RFR: 8358533: Improve performance of java.io.Reader.readAllLines [v3]

2025-06-24 Thread Brian Burkhalter
> Replaces the implementation `readAllCharsAsString().lines().toList()` with > reading into a temporary `char` array which is then processed to detect line > terminators and copy non-terminating characters into strings which are added > to the list. Brian Burkhalter has updated the pull request