Re: RFR: 8292698: Improve performance of DataInputStream [v4]

2022-10-16 Thread Jaikiran Pai
On Mon, 29 Aug 2022 08:46:20 GMT, Сергей Цыпанов wrote: >> I found out that reading from `DataInputStream` wrapping >> `ByteArrayInputStream` (as well as `BufferedInputStream` or any >> `InputStream` relying on `byte[]`) can be significantly improved by >> accessing volatile `in` field only on

Re: RFR: 8292698: Improve performance of DataInputStream [v4]

2022-10-16 Thread Jaikiran Pai
On Wed, 5 Oct 2022 15:24:10 GMT, Сергей Цыпанов wrote: > Anyone to sponsor, or should I get more approves? I see that both Alan and Daniel have approved these changes and there hasn't been a commit in this PR, after the approval (which is a good thing). I'll run some internal tests and if all

Re: RFR: 8292698: Improve performance of DataInputStream [v4]

2022-10-05 Thread Сергей Цыпанов
On Mon, 29 Aug 2022 08:46:20 GMT, Сергей Цыпанов wrote: >> I found out that reading from `DataInputStream` wrapping >> `ByteArrayInputStream` (as well as `BufferedInputStream` or any >> `InputStream` relying on `byte[]`) can be significantly improved by >> accessing volatile `in` field only on

Re: RFR: 8292698: Improve performance of DataInputStream [v4]

2022-09-16 Thread Сергей Цыпанов
On Mon, 29 Aug 2022 08:46:20 GMT, Сергей Цыпанов wrote: >> I found out that reading from `DataInputStream` wrapping >> `ByteArrayInputStream` (as well as `BufferedInputStream` or any >> `InputStream` relying on `byte[]`) can be significantly improved by >> accessing volatile `in` field only on

Re: RFR: 8292698: Improve performance of DataInputStream [v4]

2022-09-14 Thread Roger Riggs
On Mon, 29 Aug 2022 08:46:20 GMT, Сергей Цыпанов wrote: >> I found out that reading from `DataInputStream` wrapping >> `ByteArrayInputStream` (as well as `BufferedInputStream` or any >> `InputStream` relying on `byte[]`) can be significantly improved by >> accessing volatile `in` field only on

Re: RFR: 8292698: Improve performance of DataInputStream [v3]

2022-09-14 Thread Bernd
On Wed, 14 Sep 2022 07:33:32 GMT, Сергей Цыпанов wrote: > > Does that mean there is no explicit test for DataInputStream endianess > > @ecki I think this is not strictly necessary as order of bytes is explicitly > specified in JavaDoc of `DataInput` implemented by `DataInputStream` Hm, maybe I

Re: RFR: 8292698: Improve performance of DataInputStream [v3]

2022-09-14 Thread Сергей Цыпанов
On Tue, 13 Sep 2022 20:04:08 GMT, Bernd wrote: > Does that mean there is no explicit test for DataInputStream endianess @ecki I think this is not strictly necessary as order of bytes is explicitly specified in JavaDoc of `DataInput` implemented by `DataInputStream` - PR: https://g

Re: RFR: 8292698: Improve performance of DataInputStream [v3]

2022-09-13 Thread Bernd
On Thu, 25 Aug 2022 09:25:55 GMT, Alan Bateman wrote: > > What is wrong with the change? > > You'll need parentheses to make that work, changing it to use '|' would work > too. Does that mean there is no explicit test for DataInputStream endianess (if only accidential tests checking for magic

Re: RFR: 8292698: Improve performance of DataInputStream [v3]

2022-09-13 Thread Alan Bateman
On Thu, 25 Aug 2022 09:25:55 GMT, Alan Bateman wrote: >> Btw, I've tried to reimplement `readInt()` in a way similar to `readLong()`: >> >> public final int readInt() throws IOException { >> readFully(readBuffer, 0, 4); >> return (readBuffer[0] & 0xff) << 24 >> + (readBuffer[1]

Re: RFR: 8292698: Improve performance of DataInputStream [v3]

2022-09-13 Thread Сергей Цыпанов
On Thu, 25 Aug 2022 09:25:55 GMT, Alan Bateman wrote: >> Btw, I've tried to reimplement `readInt()` in a way similar to `readLong()`: >> >> public final int readInt() throws IOException { >> readFully(readBuffer, 0, 4); >> return (readBuffer[0] & 0xff) << 24 >> + (readBuffer[1]

Re: RFR: 8292698: Improve performance of DataInputStream [v4]

2022-09-12 Thread Daniel Fuchs
On Mon, 29 Aug 2022 08:46:20 GMT, Сергей Цыпанов wrote: >> I found out that reading from `DataInputStream` wrapping >> `ByteArrayInputStream` (as well as `BufferedInputStream` or any >> `InputStream` relying on `byte[]`) can be significantly improved by >> accessing volatile `in` field only on

Re: RFR: 8292698: Improve performance of DataInputStream [v3]

2022-09-12 Thread Сергей Цыпанов
On Thu, 25 Aug 2022 09:25:55 GMT, Alan Bateman wrote: >> Btw, I've tried to reimplement `readInt()` in a way similar to `readLong()`: >> >> public final int readInt() throws IOException { >> readFully(readBuffer, 0, 4); >> return (readBuffer[0] & 0xff) << 24 >> + (readBuffer[1]

Re: RFR: 8292698: Improve performance of DataInputStream [v4]

2022-08-29 Thread Сергей Цыпанов
> I found out that reading from `DataInputStream` wrapping > `ByteArrayInputStream` (as well as `BufferedInputStream` or any `InputStream` > relying on `byte[]`) can be significantly improved by accessing volatile `in` > field only once per operation. > > Current implementation does it for each

Re: RFR: 8292698: Improve performance of DataInputStream [v3]

2022-08-25 Thread Alan Bateman
On Thu, 25 Aug 2022 07:46:13 GMT, Сергей Цыпанов wrote: > What is wrong with the change? You'll need parentheses to make that work, changing it to use '|' would work too. - PR: https://git.openjdk.org/jdk/pull/9956

Re: RFR: 8292698: Improve performance of DataInputStream [v3]

2022-08-25 Thread Сергей Цыпанов
On Sun, 21 Aug 2022 20:07:10 GMT, Сергей Цыпанов wrote: >> I found out that reading from `DataInputStream` wrapping >> `ByteArrayInputStream` (as well as `BufferedInputStream` or any >> `InputStream` relying on `byte[]`) can be significantly improved by >> accessing volatile `in` field only on

Re: RFR: 8292698: Improve performance of DataInputStream

2022-08-24 Thread Daniel Fuchs
On Wed, 24 Aug 2022 06:17:19 GMT, Alan Bateman wrote: > I can't imagine a subclass of DataInputStream setting 'in' to null. If it > handles async close then it's possible that it replaces it with an input > stream where read throws IOException unconditionally. This is why the > original patch

Re: RFR: 8292698: Improve performance of DataInputStream

2022-08-23 Thread Alan Bateman
On Tue, 23 Aug 2022 18:57:07 GMT, Сергей Цыпанов wrote: > Suppose we have a scenario where `in` is replaced asynchronously in one of > implementations and the implementation is passed into constructor of > `DataInputStream`. In this case the patched code is less NPE-vulnerable, > isn't it? I

Re: RFR: 8292698: Improve performance of DataInputStream

2022-08-23 Thread Сергей Цыпанов
On Tue, 23 Aug 2022 17:12:50 GMT, Alan Bateman wrote: > The main thing is to think through the implications for async close where the > close method replaces 'in'. Suppose we have a scenario where `in` is replaced asynchronously in one of implementations and the implementation is passed into c

Re: RFR: 8292698: Improve performance of DataInputStream

2022-08-23 Thread Alan Bateman
On Tue, 23 Aug 2022 15:50:56 GMT, Daniel Fuchs wrote: > But assuming I've reverted the changes that are dubious, how could there be > bugs caused by replacement of multiple reads with a single one? I was sure > that such replacement improves thread safety as soon as we rid racy reads. The main

Re: RFR: 8292698: Improve performance of DataInputStream

2022-08-23 Thread Daniel Fuchs
On Tue, 23 Aug 2022 14:31:26 GMT, Сергей Цыпанов wrote: > > I agree that caution is warranted > > But assuming I've reverted the changes that are dubious, how could there be > bugs caused by replacement of multiple reads with a single one? I was sure > that such replacement improves thread saf

Re: RFR: 8292698: Improve performance of DataInputStream

2022-08-23 Thread Сергей Цыпанов
On Tue, 23 Aug 2022 13:57:35 GMT, Daniel Fuchs wrote: > I agree that caution is warranted But assuming I've reverted the changes that are dubious, how could there be bugs caused by replacement of multiple reads with a single one? I was sure that such replacement improves thread safety as soon

Re: RFR: 8292698: Improve performance of DataInputStream

2022-08-23 Thread Daniel Fuchs
On Sun, 21 Aug 2022 07:21:08 GMT, Alan Bateman wrote: > 'in' is a protected field so it requires thinking about subclasses that might > change 'in', say when the input stream is asynchronously closed. > BufferedInputStream is an example of a FilterInputStream that sets 'in' to > null when asyn

Re: RFR: 8292698: Improve performance of DataInputStream [v3]

2022-08-21 Thread Сергей Цыпанов
> I found out that reading from `DataInputStream` wrapping > `ByteArrayInputStream` (as well as `BufferedInputStream` or any `InputStream` > relying on `byte[]`) can be significantly improved by accessing volatile `in` > field only once per operation. > > Current implementation does it for each

Re: RFR: 8292698: Improve performance of DataInputStream [v2]

2022-08-21 Thread Сергей Цыпанов
> I found out that reading from `DataInputStream` wrapping > `ByteArrayInputStream` (as well as `BufferedInputStream` or any `InputStream` > relying on `byte[]`) can be significantly improved by accessing volatile `in` > field only once per operation. > > Current implementation does it for each

Re: RFR: 8292698: Improve performance of DataInputStream

2022-08-21 Thread Сергей Цыпанов
On Sun, 21 Aug 2022 06:29:43 GMT, Сергей Цыпанов wrote: > I found out that reading from `DataInputStream` wrapping > `ByteArrayInputStream` (as well as `BufferedInputStream` or any `InputStream` > relying on `byte[]`) can be significantly improved by accessing volatile `in` > field only once p

Re: RFR: 8292698: Improve performance of DataInputStream

2022-08-21 Thread Alan Bateman
On Sun, 21 Aug 2022 06:29:43 GMT, Сергей Цыпанов wrote: > I found out that reading from `DataInputStream` wrapping > `ByteArrayInputStream` (as well as `BufferedInputStream` or any `InputStream` > relying on `byte[]`) can be significantly improved by accessing volatile `in` > field only once p

RFR: 8292698: Improve performance of DataInputStream

2022-08-20 Thread Сергей Цыпанов
I found out that reading from `DataInputStream` wrapping `ByteArrayInputStream` (as well as `BufferedInputStream` or any `InputStream` relying on `byte[]`) can be significantly improved by accessing volatile `in` field only once per operation. Current implementation does it for each call of `in