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

2025-07-03 Thread Brian Burkhalter
On Thu, 3 Jul 2025 13:41:02 GMT, Roger Riggs wrote: >> Brian Burkhalter has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8358533: Decrease value of minGrowth parameter > > Another review would be good too. Thanks @RogerRiggs, @xuemingshe

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

2025-07-03 Thread Xueming Shen
On Wed, 2 Jul 2025 21:37:00 GMT, Brian Burkhalter wrote: >> 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

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

2025-07-03 Thread Roger Riggs
On Wed, 2 Jul 2025 21:37:00 GMT, Brian Burkhalter wrote: >> 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

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

2025-07-02 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

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

2025-07-02 Thread Roger Riggs
On Fri, 27 Jun 2025 23:00:04 GMT, Brian Burkhalter wrote: >> src/java.base/share/classes/java/io/Reader.java line 504: >> >>> 502: } >>> 503: if (fragLen >= cb.length/2) { >>> 504: // allocate larger buffer and copy chars to >>> be

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

2025-07-01 Thread Brian Burkhalter
On Tue, 1 Jul 2025 15:10:10 GMT, Brian Burkhalter wrote: >> src/java.base/share/classes/java/io/Reader.java line 482: >> >>> 480: if (pos == limit) { >>> 481: int len = limit - start; >>> 482: if (len >= cb.length) { >> >> Observation: thi

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

2025-07-01 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

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

2025-07-01 Thread Brian Burkhalter
On Tue, 1 Jul 2025 19:17:17 GMT, Roger Riggs wrote: >> With this change >> >> --- a/test/jdk/java/io/Reader/ReadAll.java >> +++ b/test/jdk/java/io/Reader/ReadAll.java >> @@ -115,6 +115,8 @@ public static void setup() throws IOException { >> sb.setLength(0); >> } >> >> +

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

2025-07-01 Thread Roger Riggs
On Tue, 1 Jul 2025 16:34:51 GMT, Brian Burkhalter wrote: >> I don't know, but I doubt it. I will look into adding something. > > With this change > > --- a/test/jdk/java/io/Reader/ReadAll.java > +++ b/test/jdk/java/io/Reader/ReadAll.java > @@ -115,6 +115,8 @@ public static void setup() throws IO

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

2025-07-01 Thread Brian Burkhalter
On Tue, 1 Jul 2025 15:10:33 GMT, Brian Burkhalter wrote: >> test/jdk/java/io/Reader/ReadAll.java line 117: >> >>> 115: sb.setLength(0); >>> 116: } >>> 117: >> >> Does one of these cases result in a *very very long line without a >> terminator"; something that would trigger

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

2025-07-01 Thread Brian Burkhalter
On Tue, 1 Jul 2025 01:37:27 GMT, Roger Riggs wrote: > I think resizing the buffer when the line length exceeds cb.length/2 will be > more efficient (cpu wise). I concur. I missed that this had been changed in the most recent commit. > test/jdk/java/io/Reader/ReadAll.java line 117: > >> 115:

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

2025-06-30 Thread Roger Riggs
On Mon, 30 Jun 2025 19:38:59 GMT, Brian Burkhalter wrote: >> 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

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

2025-06-30 Thread Roger Riggs
On Mon, 30 Jun 2025 19:38:59 GMT, Brian Burkhalter wrote: >> 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

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

2025-06-30 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

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

2025-06-30 Thread Brian Burkhalter
On Mon, 30 Jun 2025 18:28:26 GMT, Xueming Shen wrote: > the throughput appears to back to normal with 'find term while loop' fast path This version passes the regression test and is a little faster than the latest PR version. I'll run it through the CI and probably use it in the next commit. T

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

2025-06-30 Thread Xueming Shen
On Fri, 27 Jun 2025 19:41:01 GMT, Brian Burkhalter wrote: >> 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

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

2025-06-30 Thread Brian Burkhalter
On Sat, 28 Jun 2025 08:41:27 GMT, Xueming Shen wrote: > The modified code below is a PoC for reference. It seems to work as expected, > though not fully tested. This looks like a nice reworking, and appears to pass the regression test, but its throughput is less than half that of the current v

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

2025-06-28 Thread Xueming Shen
On Fri, 27 Jun 2025 19:41:01 GMT, Brian Burkhalter wrote: >> 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

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

2025-06-27 Thread Brian Burkhalter
On Fri, 27 Jun 2025 22:46:40 GMT, Xueming Shen wrote: > [...] more in line with how resizing is handled in string builder Looks like `StringBuilder` eventually calls `ArraysSupport.newLength(int,int.int)`. This is probably worth checking out. - PR Review Comment: https://git.openj

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

2025-06-27 Thread Xueming Shen
On Fri, 27 Jun 2025 17:32:25 GMT, Brian Burkhalter wrote: >> 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

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

2025-06-27 Thread Brian Burkhalter
On Fri, 27 Jun 2025 19:21:19 GMT, Roger Riggs wrote: > More directly, use limit instead of term in the computation of length. Good point. So changed in 3e5e498. - PR Review Comment: https://git.openjdk.org/jdk/pull/25863#discussion_r2172749427

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

2025-06-27 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

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

2025-06-27 Thread Roger Riggs
On Fri, 27 Jun 2025 18:54:20 GMT, Brian Burkhalter wrote: >> Yes, `term == limit`. The "no line terminator" means none was encountered >> before the buffer's end was reached. > > Maybe it should be something like: > > // no line terminator before end of buffer More directly, use limit instead

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

2025-06-27 Thread Brian Burkhalter
On Fri, 27 Jun 2025 18:52:14 GMT, Brian Burkhalter wrote: >> src/java.base/share/classes/java/io/Reader.java line 494: >> >>> 492: skipLF = isCR; >>> 493: } else { // no line terminator >>> 494: int len = term - pos; >> >> I think term ==

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

2025-06-27 Thread Brian Burkhalter
On Fri, 27 Jun 2025 18:44:55 GMT, Roger Riggs wrote: >> Brian Burkhalter has updated the pull request incrementally with two >> additional commits since the last revision: >> >> - 8358533: Use a boolean instead of fragPos != -1 >> - 8358533: Immediately skip LF right after CR > > src/java.bas

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

2025-06-27 Thread Roger Riggs
On Fri, 27 Jun 2025 17:32:25 GMT, Brian Burkhalter wrote: >> 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

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

2025-06-27 Thread Brian Burkhalter
On Fri, 27 Jun 2025 15:36:29 GMT, Roger Riggs wrote: >> Brian Burkhalter has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8358533: Test change accidentally omitted from previous commit > > src/java.base/share/classes/java/io/Reader.java l

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

2025-06-27 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

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

2025-06-27 Thread Roger Riggs
On Fri, 27 Jun 2025 15:03:05 GMT, Brian Burkhalter wrote: >> 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

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

2025-06-27 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

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

2025-06-26 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

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

2025-06-26 Thread Brian Burkhalter
On Tue, 24 Jun 2025 19:15:38 GMT, Brian Burkhalter 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. In 0ee3f59 I implemented something like this. It is a bit faster than the currec

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

2025-06-25 Thread Roger Riggs
On Wed, 25 Jun 2025 19:57:56 GMT, Xueming Shen wrote: >> Fixed in >> [d5abfa4](https://github.com/openjdk/jdk/pull/25863/commits/d5abfa450cb3fcd604560833038735e41952bce9 >> ). > > My apologies if this is a naive question :-) I'm sure this was discussed when > the method was added, so this is ju

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

2025-06-25 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

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

2025-06-25 Thread Xueming Shen
On Tue, 24 Jun 2025 18:51:04 GMT, Brian Burkhalter wrote: >> Right, the specification here requires an unmodifiable List, so an >> unmodifiable wrapper or a list from `List.copyOf()` is appropriate. > > Fixed in > [d5abfa4](https://github.com/openjdk/jdk/pull/25863/commits/d5abfa450cb3fcd604560

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

2025-06-24 Thread Brian Burkhalter
On Wed, 18 Jun 2025 00:05:17 GMT, Brian Burkhalter wrote: > The throughput of the implementation [...]. The performance comments made [here](https://github.com/openjdk/jdk/pull/25863#issuecomment-2982169343) still apply to the most recent commit. - PR Comment: https://git.openjdk

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

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

2025-06-24 Thread Johannes Döbler
On Tue, 24 Jun 2025 14:42:57 GMT, Brian Burkhalter wrote: >> 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

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

2025-06-24 Thread Brian Burkhalter
On Wed, 18 Jun 2025 00:04:37 GMT, Brian Burkhalter wrote: > 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 >

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

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

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

2025-06-24 Thread Andrey Turbanov
On Wed, 18 Jun 2025 00:04:37 GMT, Brian Burkhalter wrote: > 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 >

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

2025-06-23 Thread Stuart Marks
On Thu, 19 Jun 2025 11:08:32 GMT, Markus KARG wrote: >> 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 >>

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

2025-06-23 Thread Stuart Marks
On Thu, 19 Jun 2025 10:57:52 GMT, Markus KARG wrote: >>> I think we should treat "\r\n" as a single line terminator? >> >> You are correct: that needs to be fixed: >> >> jshell> Reader r = new StringReader("hello\r\nworld") >> r ==> java.io.StringReader@480bdb19 >> >> jshell> r.readAllLines()

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

2025-06-20 Thread Xueming Shen
On Fri, 20 Jun 2025 15:52:08 GMT, Roger Riggs wrote: >> My suggestion is to call `new StringBuilder(0)` as it is possible this is >> completely unused because we always hit the `eol && sb.length() == 0` path >> below. > > The change is motivated by performance, but there will be many inputs tha

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

2025-06-20 Thread Chen Liang
On Thu, 19 Jun 2025 10:53:14 GMT, Markus KARG wrote: >>> Is there a reason for this pre-allocation? >> >> What would you suggest? Start with a smaller allocation and increase it if >> needed? There is no possibility of knowing the length of the stream. > > As this PR explicitly targets performa

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

2025-06-20 Thread Roger Riggs
On Fri, 20 Jun 2025 15:50:53 GMT, Chen Liang wrote: >> As this PR explicitly targets performance and as the aim of this method is >> to keep **all** content in-memory anyways, I wonder if it would be >> acceptable and even faster to pre-allocate `new >> StringBuilder(TRANSFER_BUFFER_SIZE)`? In

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

2025-06-19 Thread Markus KARG
On Wed, 18 Jun 2025 00:04:37 GMT, Brian Burkhalter wrote: > 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 >

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

2025-06-19 Thread Markus KARG
On Wed, 18 Jun 2025 16:57:22 GMT, Brian Burkhalter wrote: >> src/java.base/share/classes/java/io/Reader.java line 455: >> >>> 453: List lines = new ArrayList(); >>> 454: >>> 455: StringBuilder sb = new StringBuilder(82); >> >> Is there a reason for this pre-allocation? If the w

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

2025-06-19 Thread Markus KARG
On Wed, 18 Jun 2025 16:45:33 GMT, Brian Burkhalter wrote: >> I think we should treat "\r\n" as a single line terminator? for example >> >> "hello\r\nworld".lines().forEach(line -> out.format("[%s]\n", line)); >> => >> [hello] >> [world] >> >> instead of (the current impl) >> >> [hello] >> []

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

2025-06-18 Thread Brian Burkhalter
On Wed, 18 Jun 2025 02:26:48 GMT, Chen Liang wrote: > Is there a reason for this pre-allocation? What would you suggest? Start with a smaller allocation and increase it if needed? There is no possibility of knowing the length of the stream. - PR Review Comment: https://git.openjdk

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

2025-06-18 Thread Brian Burkhalter
On Wed, 18 Jun 2025 02:38:04 GMT, Chen Liang wrote: > Edit: No, we need to check empty lines. Right. I caught this during testing. - PR Review Comment: https://git.openjdk.org/jdk/pull/25863#discussion_r2155088265

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

2025-06-18 Thread Brian Burkhalter
On Wed, 18 Jun 2025 02:33:40 GMT, Xueming Shen wrote: > I think we should treat "\r\n" as a single line terminator? You are correct: that needs to be fixed: jshell> Reader r = new StringReader("hello\r\nworld") r ==> java.io.StringReader@480bdb19 jshell> r.readAllLines() $3 ==> [hello, , world

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

2025-06-18 Thread Brian Burkhalter
On Wed, 18 Jun 2025 09:20:12 GMT, Shaojin Wen wrote: > If we want better performance, we should go a step further and overload the > readAllLines method in the Reader implementation class. Perhaps, but not in this request. A separate issue should be filed and addressed subsequently. -

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

2025-06-18 Thread Shaojin Wen
On Wed, 18 Jun 2025 00:04:37 GMT, Brian Burkhalter wrote: > 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 >

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

2025-06-17 Thread Chen Liang
On Wed, 18 Jun 2025 00:04:37 GMT, Brian Burkhalter wrote: > 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 >

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

2025-06-17 Thread Xueming Shen
On Wed, 18 Jun 2025 01:34:14 GMT, Brian Burkhalter wrote: >> src/java.base/share/classes/java/io/Reader.java line 469: >> >>> 467: if (c == '\r' || c == '\n') >>> 468: break; >>> 469: term++; >> >> It might be worth adding a test o

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

2025-06-17 Thread Shaojin Wen
On Wed, 18 Jun 2025 00:04:37 GMT, Brian Burkhalter wrote: > 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 >

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

2025-06-17 Thread Shaojin Wen
On Wed, 18 Jun 2025 00:04:37 GMT, Brian Burkhalter wrote: > 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 >

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

2025-06-17 Thread Brian Burkhalter
On Wed, 18 Jun 2025 00:53:51 GMT, Roger Riggs wrote: >> 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 >>

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

2025-06-17 Thread Roger Riggs
On Wed, 18 Jun 2025 00:04:37 GMT, Brian Burkhalter wrote: > 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 >

RFR: 8358533: Improve performance of java.io.Reader.readAllLines

2025-06-17 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. - Commit messages: - 8358533: Improve p

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

2025-06-17 Thread Brian Burkhalter
On Wed, 18 Jun 2025 00:04:37 GMT, Brian Burkhalter wrote: > 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 >