Re: RFR: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream [v3]

2023-03-29 Thread Per Minborg
On Tue, 28 Mar 2023 18:15:57 GMT, Eirik Bjorsnos wrote: > > @eirbjo I've updated the PR so we hold zero-length arrays rather than null > > arrays. Please re-run your benchmark to see if there is any change. > > @minborg I ran the test now after your integration and I no longer observe > the re

Re: RFR: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream [v3]

2023-03-28 Thread Eirik Bjorsnos
On Thu, 23 Mar 2023 14:00:40 GMT, Eirik Bjorsnos wrote: >> I cannot explain why, but the changes suggested in this PR seem to introduce >> a small, but significant performance regression on the >> `DataInputStreamTest.readInt` benchmark: >> >> Baseline: >> >> >> Benchmark

Re: RFR: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream [v5]

2023-03-28 Thread Alan Bateman
On Tue, 28 Mar 2023 08:13:31 GMT, Per Minborg wrote: >> This PR proposed to lazily initialize the scratch arrays only if/when needed. > > Per Minborg has updated the pull request with a new target base due to a > merge or a rebase. The incremental webrev excludes the unrelated changes > brought

Re: RFR: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream [v4]

2023-03-28 Thread Per Minborg
On Tue, 28 Mar 2023 07:21:15 GMT, Per Minborg wrote: >> This PR proposed to lazily initialize the scratch arrays only if/when needed. > > Per Minborg has updated the pull request incrementally with one additional > commit since the last revision: > > Use zero-lenght arrays rather than null W

Re: RFR: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream [v5]

2023-03-28 Thread Per Minborg
> This PR proposed to lazily initialize the scratch arrays only if/when needed. Per Minborg has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains seven additi

Re: RFR: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream [v3]

2023-03-28 Thread Per Minborg
On Thu, 23 Mar 2023 14:00:40 GMT, Eirik Bjorsnos wrote: >> I cannot explain why, but the changes suggested in this PR seem to introduce >> a small, but significant performance regression on the >> `DataInputStreamTest.readInt` benchmark: >> >> Baseline: >> >> >> Benchmark

Re: RFR: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream [v4]

2023-03-28 Thread Per Minborg
> This PR proposed to lazily initialize the scratch arrays only if/when needed. Per Minborg has updated the pull request incrementally with one additional commit since the last revision: Use zero-lenght arrays rather than null - Changes: - all: https://git.openjdk.org/jdk/pull/

Re: RFR: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream [v3]

2023-03-23 Thread altrisi
On Wed, 22 Mar 2023 10:12:26 GMT, Per Minborg wrote: >> This PR proposed to lazily initialize the scratch arrays only if/when needed. > > Per Minborg has updated the pull request with a new target base due to a > merge or a rebase. The incremental webrev excludes the unrelated changes > brought

Re: RFR: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream [v3]

2023-03-23 Thread Eirik Bjorsnos
On Thu, 23 Mar 2023 13:51:35 GMT, Eirik Bjorsnos wrote: > The reason this puzzles me is that the `readInt` benchmark don't involve the > UTF code paths at all. So why would it become slower, just because two fields > are no longer initialized with the default arrays? Could there be some JIT op

Re: RFR: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream [v3]

2023-03-23 Thread Eirik Bjorsnos
On Wed, 22 Mar 2023 10:12:26 GMT, Per Minborg wrote: >> This PR proposed to lazily initialize the scratch arrays only if/when needed. > > Per Minborg has updated the pull request with a new target base due to a > merge or a rebase. The incremental webrev excludes the unrelated changes > brought

Re: RFR: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream

2023-03-23 Thread Alan Bateman
On Wed, 22 Mar 2023 10:17:36 GMT, Per Minborg wrote: > > Nice idea. Just wonder could we do the same for `BufferedInputStream`? > > I think it is doable but would require some more work as nullity is used as a > "closed flag". I would nervous about changing BIS. The buf field is a protected fi

Re: RFR: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream [v3]

2023-03-22 Thread Alan Bateman
On Wed, 22 Mar 2023 10:12:26 GMT, Per Minborg wrote: >> This PR proposed to lazily initialize the scratch arrays only if/when needed. > > Per Minborg has updated the pull request with a new target base due to a > merge or a rebase. The incremental webrev excludes the unrelated changes > brought

Re: RFR: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream [v3]

2023-03-22 Thread Alan Bateman
On Wed, 22 Mar 2023 10:07:57 GMT, Per Minborg wrote: >> src/java.base/share/classes/java/io/DataInputStream.java line 64: >> >>> 62: * working arrays initialized on demand by readUTF >>> 63: */ >>> 64: private byte[] bytearr; >> >> Could the `bytearr` and `chararr` instance variab

Re: RFR: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream

2023-03-22 Thread Per Minborg
On Tue, 21 Mar 2023 20:35:36 GMT, Sergey Tsypanov wrote: > Nice idea. Just wonder could we do the same for `BufferedInputStream`? I think it is doable but would require some more work as nullity is used as a "closed flag". Please raise a separate issue about this. - PR Comment: ht

Re: RFR: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream

2023-03-22 Thread Per Minborg
On Tue, 21 Mar 2023 17:27:42 GMT, Eirik Bjorsnos wrote: > Looks like `DataInputStream.readUTF` could benefit from using > `JavaLangAccess.countPositives` and return early for the common case that all > bytes are ASCII. Food for another PR? Yep. Please raise an issue with the ideas around this

Re: RFR: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream [v3]

2023-03-22 Thread Per Minborg
> This PR proposed to lazily initialize the scratch arrays only if/when needed. Per Minborg has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains five additio

Re: RFR: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream [v3]

2023-03-22 Thread Per Minborg
On Tue, 21 Mar 2023 16:17:35 GMT, Brian Burkhalter wrote: >> Per Minborg has updated the pull request with a new target base due to a >> merge or a rebase. The incremental webrev excludes the unrelated changes >> brought in by the merge/rebase. The pull request contains five additional >> comm

Re: RFR: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream [v2]

2023-03-22 Thread Per Minborg
> This PR proposed to lazily initialize the scratch arrays only if/when needed. Per Minborg has updated the pull request incrementally with one additional commit since the last revision: Update src/java.base/share/classes/java/io/DataInputStream.java Co-authored-by: Eirik Bjorsnos -

Re: RFR: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream

2023-03-21 Thread Sergey Tsypanov
On Tue, 21 Mar 2023 15:41:13 GMT, Per Minborg wrote: > This PR proposed to lazily initialize the scratch arrays only if/when needed. Nice idea. Just wonder could we do the same for `BufferedInputStream`? - PR Comment: https://git.openjdk.org/jdk/pull/13121#issuecomment-1478546070

Re: RFR: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream

2023-03-21 Thread Eirik Bjorsnos
On Tue, 21 Mar 2023 15:41:13 GMT, Per Minborg wrote: > This PR proposed to lazily initialize the scratch arrays only if/when needed. Looks like `DataInputStream.readUTF` could benefit from using `JavaLangAccess.countPositives` and return early for the common case that all bytes are ASCII. Food

Re: RFR: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream

2023-03-21 Thread Brian Burkhalter
On Tue, 21 Mar 2023 15:41:13 GMT, Per Minborg wrote: > This PR proposed to lazily initialize the scratch arrays only if/when needed. src/java.base/share/classes/java/io/DataInputStream.java line 64: > 62: * working arrays initialized on demand by readUTF > 63: */ > 64: private byt

Re: RFR: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream

2023-03-21 Thread Eirik Bjorsnos
On Tue, 21 Mar 2023 15:41:13 GMT, Per Minborg wrote: > This PR proposed to lazily initialize the scratch arrays only if/when needed. Looks good. Many DataInputStreams probably never read UTF. (Not a reviewer) src/java.base/share/classes/java/io/DataInputStream.java line 576: > 574: cha

RFR: 8300979: Lazily initialize (byte, char)arr in java.io.DataInputStream

2023-03-21 Thread Per Minborg
This PR proposed to lazily initialize the scratch arrays only if/when needed. - Commit messages: - Remove redundant initilizers - Lazily initialize (byte, char)arr in java.io.DataInputStream Changes: https://git.openjdk.org/jdk/pull/13121/files Webrev: https://webrevs.openjdk.org/