Re: RFR: 8322292: Rearrange comparison of fields in Record.equals() [v6]

2024-01-20 Thread Sergey Tsypanov
On Fri, 22 Dec 2023 13:00:11 GMT, Sergey Tsypanov wrote: >> Currently if we create a record it's fields are compared in their >> declaration order. This might be ineffective in cases when two objects have >> "heavy" fields equals to each other, but different &q

Re: RFR: 8322877: java/io/BufferedInputStream/TransferTo.java failed with IndexOutOfBoundsException

2024-01-03 Thread Sergey Tsypanov
On Wed, 3 Jan 2024 18:01:59 GMT, Brian Burkhalter wrote: > The final position instead of the number of bytes to write was being passed > to `ByteArrayOuputStream.write(byte[],int,int)`. Marked as reviewed by stsypanov (Author). - PR Review: https://git.openjdk.org/jdk/pull/17250#p

Integrated: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted

2024-01-02 Thread Sergey Tsypanov
On Wed, 29 Nov 2023 11:57:37 GMT, Sergey Tsypanov wrote: > It looks like we can skip copying of `byte[]` in > `BufferedInputStream.implTransferTo()` for `OutputStreams` residing in > `java.io`. > > See comment by @vlsi in > https://github.com/openjdk/jdk/pul

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v20]

2024-01-02 Thread Sergey Tsypanov
e677ecbd977af1R612 Sergey Tsypanov has updated the pull request incrementally with one additional commit since the last revision: Update TransferToTrusted.java - Changes: - all: https://git.openjdk.org/jdk/pull/16879/files - new: https://git.openjdk.org/jdk/pull/16879/files/

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v18]

2023-12-30 Thread Sergey Tsypanov
On Sat, 30 Dec 2023 17:52:41 GMT, Markus KARG wrote: >> `com.sun.management.ThreadMXBean#getCurrentThreadAllocatedBytes` is >> reliable, isn't it? > > According to its JavaDocs it only returns *an approximation*, whatever that > means. And it is measuring memory, while I already explained that

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v18]

2023-12-30 Thread Sergey Tsypanov
On Sat, 30 Dec 2023 12:05:22 GMT, Alan Bateman wrote: >> Sergey Tsypanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8320971: Fix test > > src/java.base/share/classes/java/io/BufferedInputStream.java li

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v19]

2023-12-30 Thread Sergey Tsypanov
e677ecbd977af1R612 Sergey Tsypanov has updated the pull request incrementally with one additional commit since the last revision: 8320971: Fix JavaDoc - Changes: - all: https://git.openjdk.org/jdk/pull/16879/files - new: https://git.openjdk.org/jdk/pull/16879/files/41a7f1a7.

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v18]

2023-12-28 Thread Sergey Tsypanov
e677ecbd977af1R612 Sergey Tsypanov has updated the pull request incrementally with one additional commit since the last revision: 8320971: Fix test - Changes: - all: https://git.openjdk.org/jdk/pull/16879/files - new: https://git.openjdk.org/jdk/pull/16879/files/ee035998..41a7f1a7

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v18]

2023-12-28 Thread Sergey Tsypanov
On Sat, 23 Dec 2023 23:18:40 GMT, Markus KARG wrote: >> Yeah, but how could I intercept the argument of OutputStream.write() and >> check it's identity? > > As I wrote earlier today to Vladimir (see above) I actually do not see a > solution for this, frankly spoken, as the interceptor would not

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v18]

2023-12-28 Thread Sergey Tsypanov
On Sat, 23 Dec 2023 13:08:06 GMT, Markus KARG wrote: >> Sergey Tsypanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8320971: Fix test > > test/jdk/java/io/BufferedInputStream/TransferTo

Re: RFR: 8322292: Rearrange comparison of fields in Record.equals() [v5]

2023-12-22 Thread Sergey Tsypanov
On Thu, 21 Dec 2023 19:43:50 GMT, ExE Boss wrote: >> src/java.base/share/classes/java/lang/runtime/ObjectMethods.java line 224: >> >>> 222: var rt2 = mh2.type().returnType(); >>> 223: return Integer.compare( >>> 224: rt1.isPrimitive() || rt1.isEnum() || rt

Re: RFR: 8322292: Rearrange comparison of fields in Record.equals() [v6]

2023-12-22 Thread Sergey Tsypanov
L1 > LOCALVARIABLE this > Lcom/caspianone/openbanking/productservice/controller/MyRecord; L0 L1 0 > LOCALVARIABLE o Ljava/lang/Object; L0 L1 1 > MAXSTACK = 2 > MAXLOCALS = 2 > > This can be improved by rearranging the comparison order of the fields moving

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v17]

2023-12-22 Thread Sergey Tsypanov
e677ecbd977af1R612 Sergey Tsypanov 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 22 additional commits since the last revision: - Merge branch &#x

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v16]

2023-12-22 Thread Sergey Tsypanov
On Thu, 21 Dec 2023 17:29:16 GMT, Brian Burkhalter wrote: >> Sergey Tsypanov 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 cont

Re: RFR: 8322292: Rearrange comparison of fields in Record.equals() [v5]

2023-12-21 Thread Sergey Tsypanov
L1 > LOCALVARIABLE this > Lcom/caspianone/openbanking/productservice/controller/MyRecord; L0 L1 0 > LOCALVARIABLE o Ljava/lang/Object; L0 L1 1 > MAXSTACK = 2 > MAXLOCALS = 2 > > This can be improved by rearranging the comparison order of the fields moving

Re: RFR: 8294961: Convert java.base/java.lang.reflect.ProxyGenerator to use the Classfile API to generate proxy classes [v3]

2023-12-21 Thread Sergey Tsypanov
On Thu, 21 Dec 2023 01:12:07 GMT, Adam Sotona wrote: >> java.base java.lang.reflect.ProxyGenerator uses ASM to generate proxy >> classes. >> >> This patch converts it to use Classfile API. >> >> It is continuation of https://github.com/openjdk/jdk/pull/10991 >> >> Any comments and suggestions

Re: RFR: 8322292: Rearrange comparison of fields in Record.equals() [v4]

2023-12-20 Thread Sergey Tsypanov
L1 > LOCALVARIABLE this > Lcom/caspianone/openbanking/productservice/controller/MyRecord; L0 L1 0 > LOCALVARIABLE o Ljava/lang/Object; L0 L1 1 > MAXSTACK = 2 > MAXLOCALS = 2 > > This can be improved by rearranging the comparison order of the fields moving

Re: RFR: 8322292: Rearrange comparison of fields in Record.equals() [v3]

2023-12-19 Thread Sergey Tsypanov
L1 > LOCALVARIABLE this > Lcom/caspianone/openbanking/productservice/controller/MyRecord; L0 L1 0 > LOCALVARIABLE o Ljava/lang/Object; L0 L1 1 > MAXSTACK = 2 > MAXLOCALS = 2 > > This can be improved by rearranging the comparison order of the fields moving

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v15]

2023-12-19 Thread Sergey Tsypanov
On Sat, 16 Dec 2023 17:51:30 GMT, Markus KARG wrote: >> Sergey Tsypanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8320971: Revert irrelevant changes > > test/jdk/java/io/BufferedInputStream/TransferTo

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v16]

2023-12-19 Thread Sergey Tsypanov
e677ecbd977af1R612 Sergey Tsypanov 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 20 additional commits since the last revision:

Re: RFR: 8322292: Rearrange comparison of fields in Record.equals() [v2]

2023-12-19 Thread Sergey Tsypanov
L1 > LOCALVARIABLE this > Lcom/caspianone/openbanking/productservice/controller/MyRecord; L0 L1 0 > LOCALVARIABLE o Ljava/lang/Object; L0 L1 1 > MAXSTACK = 2 > MAXLOCALS = 2 > > This can be improved by rearranging the comparison order of the fields moving

Re: RFR: 8322292: Rearrange comparison of fields in Record.equals()

2023-12-19 Thread Sergey Tsypanov
On Tue, 19 Dec 2023 06:07:31 GMT, Hannes Greule wrote: > Arrays are compared by reference Isn't `Arrays.equals()` used under the hood? > You are sorting the array passed to the bootstrap method Good point, fixed. - PR Comment: https://git.openjdk.org/jdk/pull/17143#issuecomment-1

RFR: 8322292: Rearrange comparison of fields in Record.equals()

2023-12-18 Thread Sergey Tsypanov
Currently if we create a record it's fields are compared in their declaration order. This might be ineffective in cases when two objects have "heavy" fields equals to each other, but different "lightweight" fields (heavy and lightweight in terms of comparison) e.g. primitives, enums, nullable/no

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v15]

2023-12-15 Thread Sergey Tsypanov
On Fri, 15 Dec 2023 17:21:52 GMT, Brian Burkhalter wrote: >> I think this would be doing double job, wouldn't it? > >> I think this would be doing double job, wouldn't it? > > Sorry, I don't understand. If we drop the method for now I have to write it later again, I guess - PR Rev

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v15]

2023-12-15 Thread Sergey Tsypanov
On Thu, 14 Dec 2023 23:04:25 GMT, Brian Burkhalter wrote: >> Sergey Tsypanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8320971: Revert irrelevant changes > > src/java.base/share/classes/java/io/Buf

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v15]

2023-12-14 Thread Sergey Tsypanov
e677ecbd977af1R612 Sergey Tsypanov has updated the pull request incrementally with one additional commit since the last revision: 8320971: Revert irrelevant changes - Changes: - all: https://git.openjdk.org/jdk/pull/16879/files - new: https://git.openjdk.org/jdk/pull/16879/files/

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v13]

2023-12-13 Thread Sergey Tsypanov
On Wed, 13 Dec 2023 16:46:16 GMT, Alan Bateman wrote: >>> It doesn't make sense here to add a new package com.sun.io for a single >>> method class. This PR does not need to introduce any new classes at this >>> point. I think this PR needs to focus solely on BIS. >> >> So you actually prefer c

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v13]

2023-12-13 Thread Sergey Tsypanov
On Wed, 13 Dec 2023 09:09:29 GMT, Alan Bateman wrote: >> Sergey Tsypanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8320971: Fix JavaDoc > > src/java.base/share/classes/com/sun/io/IOStreams.java line 2

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v12]

2023-12-13 Thread Sergey Tsypanov
On Wed, 13 Dec 2023 08:04:59 GMT, Markus KARG wrote: >> Sergey Tsypanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8320971: Whitespaces > > src/java.base/share/classes/com/sun/io/IOStreams.java line 5

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v14]

2023-12-13 Thread Sergey Tsypanov
e677ecbd977af1R612 Sergey Tsypanov has updated the pull request incrementally with one additional commit since the last revision: 8320971: Add more tests - Changes: - all: https://git.openjdk.org/jdk/pull/16879/files - new: https://git.openjdk.org/jdk/pull/16879/files/c6696e27.

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v13]

2023-12-13 Thread Sergey Tsypanov
e677ecbd977af1R612 Sergey Tsypanov has updated the pull request incrementally with one additional commit since the last revision: 8320971: Fix JavaDoc - Changes: - all: https://git.openjdk.org/jdk/pull/16879/files - new: https://git.openjdk.org/jdk/pull/16879/files/a3ba43fd.

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v9]

2023-12-12 Thread Sergey Tsypanov
On Mon, 11 Dec 2023 19:53:40 GMT, Sergey Tsypanov wrote: >> src/java.base/share/classes/java/io/IOStreams.java line 1: >> >>> 1: /* >> >> Please fix Whitespace errors. Thanks. :-) > > I've just copy-pasted the header from another class. How shou

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v12]

2023-12-12 Thread Sergey Tsypanov
e677ecbd977af1R612 Sergey Tsypanov has updated the pull request incrementally with one additional commit since the last revision: 8320971: Whitespaces - Changes: - all: https://git.openjdk.org/jdk/pull/16879/files - new: https://git.openjdk.org/jdk/pull/16879/files/50e4e4e5.

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v11]

2023-12-11 Thread Sergey Tsypanov
e677ecbd977af1R612 Sergey Tsypanov has updated the pull request incrementally with one additional commit since the last revision: 8320971: Fix build - Changes: - all: https://git.openjdk.org/jdk/pull/16879/files - new: https://git.openjdk.org/jdk/pull/16879/files/3576a172..50e4e4e5

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v9]

2023-12-11 Thread Sergey Tsypanov
On Mon, 11 Dec 2023 14:58:57 GMT, Markus KARG wrote: >> Sergey Tsypanov 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 cont

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v10]

2023-12-11 Thread Sergey Tsypanov
e677ecbd977af1R612 Sergey Tsypanov has updated the pull request incrementally with one additional commit since the last revision: 8320971: Move IOStreams to com.sun.io - Changes: - all: https://git.openjdk.org/jdk/pull/16879/files - new: https://git.openjdk.org/jdk/pull/16879/files/

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v9]

2023-12-11 Thread Sergey Tsypanov
On Mon, 11 Dec 2023 14:54:37 GMT, Markus KARG wrote: >> Sergey Tsypanov 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 cont

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v9]

2023-12-11 Thread Sergey Tsypanov
e677ecbd977af1R612 Sergey Tsypanov 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 11 additional commits since the last revision: - Merge branch &#x

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v8]

2023-12-10 Thread Sergey Tsypanov
e677ecbd977af1R612 Sergey Tsypanov has updated the pull request incrementally with one additional commit since the last revision: 8320971: Extract utility class - Changes: - all: https://git.openjdk.org/jdk/pull/16879/files - new: https://git.openjdk.org/jdk/pull/16879/files/

Re: RFR: 8321620: Optimize JImage decompressors

2023-12-08 Thread Sergey Tsypanov
On Wed, 8 Nov 2023 11:55:22 GMT, Glavo wrote: > This PR significantly speeds up decompressing resources in Jimage while > significantly reducing temporary memory allocations in the process. > > This will improve startup speed for runtime images generated using `jlink > --compress 1` and `jlink

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v7]

2023-12-08 Thread Sergey Tsypanov
e677ecbd977af1R612 Sergey Tsypanov has updated the pull request incrementally with one additional commit since the last revision: 8320971: Rearrange code - Changes: - all: https://git.openjdk.org/jdk/pull/16879/files - new: https://git.openjdk.org/jdk/pull/16879/files/9bf4e22d.

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v6]

2023-12-08 Thread Sergey Tsypanov
e677ecbd977af1R612 Sergey Tsypanov has updated the pull request incrementally with one additional commit since the last revision: 8320971: Rewrite comment - Changes: - all: https://git.openjdk.org/jdk/pull/16879/files - new: https://git.openjdk.org/jdk/pull/16879/files/69fb33f6.

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v5]

2023-12-08 Thread Sergey Tsypanov
On Fri, 8 Dec 2023 17:23:59 GMT, Markus KARG wrote: >> Sergey Tsypanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8320971: Use same approach as BAOS > > src/java.base/share/classes/java/io/OutputS

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v5]

2023-12-08 Thread Sergey Tsypanov
e677ecbd977af1R612 Sergey Tsypanov has updated the pull request incrementally with one additional commit since the last revision: 8320971: Use same approach as BAOS - Changes: - all: https://git.openjdk.org/jdk/pull/16879/files - new: https://git.openjdk.org/jdk/pull/16879/files/

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v4]

2023-12-08 Thread Sergey Tsypanov
e677ecbd977af1R612 Sergey Tsypanov 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 commits since the last revision: - Merge branch &#x

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v2]

2023-11-30 Thread Sergey Tsypanov
On Thu, 30 Nov 2023 09:36:01 GMT, Bernd wrote: >> Sergey Tsypanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8320971: Trust any OutputStream from java.* > > Did you review if all Java.* streams are saf

Re: RFR: 8321053: Use ByteArrayInputStream.buf directly when parameter of transferTo() is trusted

2023-11-30 Thread Sergey Tsypanov
On Thu, 30 Nov 2023 00:03:21 GMT, Brian Burkhalter wrote: > Pass `ByteArrayInputStream.buf ` directly to the `OutputStream` parameter of > `BAIS.transferTo` only if the target stream is in the `java.io` package. src/java.base/share/classes/java/io/ByteArrayInputStream.java line 211: > 209:

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v3]

2023-11-30 Thread Sergey Tsypanov
e677ecbd977af1R612 Sergey Tsypanov has updated the pull request incrementally with one additional commit since the last revision: 8320971: Add test - Changes: - all: https://git.openjdk.org/jdk/pull/16879/files - new: https://git.openjdk.org/jdk/pull/16879/files/7779aaca..a77208e0

Re: RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v2]

2023-11-30 Thread Sergey Tsypanov
e677ecbd977af1R612 Sergey Tsypanov has updated the pull request incrementally with one additional commit since the last revision: 8320971: Trust any OutputStream from java.* - Changes: - all: https://git.openjdk.org/jdk/pull/16879/files - new: https://git.openjdk.org/jdk/pull/16

RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted

2023-11-29 Thread Sergey Tsypanov
It looks like we can skip copying of `byte[]` in `BufferedInputStream.implTransferTo()` for `OutputStreams` residing in `java.io`. See comment by @vlsi in https://github.com/openjdk/jdk/pull/10525/files#diff-e19c508d1bb6ee78697ecca66947c395adda0d9c49a85bf696e677ecbd977af1R612 - Co

Withdrawn: 8315351: Rid synchronization in PipedInputStream.close() in favour of benign race

2023-08-30 Thread Sergey Tsypanov
On Wed, 30 Aug 2023 09:49:39 GMT, Sergey Tsypanov wrote: > Assuming that the value written into `in` is always `-1` we can rid > synchronized block in favour of guarding `in = - 1` with writing into > volatile `closedByReader `: > > public void close() thr

RFR: 8315351: Rid synchronization in PipedInputStream.close() in favour of benign race

2023-08-30 Thread Sergey Tsypanov
Assuming that the value written into `in` is always `-1` we can rid synchronized block in favour of guarding `in = - 1` with writing into volatile `closedByReader `: public void close() throws IOException { closedByReader = true; synchronized (this) { in = -1; } } --> publi

Re: RFR: 8314129: Make fields final in java.util.Scanner

2023-08-10 Thread Sergey Tsypanov
On Thu, 13 Jul 2023 08:57:05 GMT, Andrey Turbanov wrote: > Made a few fields `final` in java.util.Scanner. > Also made `digits`, `non0Digit`, `SIMPLE_GROUP_INDEX` as `static.` Marked as reviewed by stsypanov (Author). - PR Review: https://git.openjdk.org/jdk/pull/14863#pullrequestr

Integrated: 8313768: Reduce interaction with volatile field in j.u.l.StreamHandler

2023-08-09 Thread Sergey Tsypanov
On Fri, 4 Aug 2023 14:51:35 GMT, Sergey Tsypanov wrote: > In `publish0()`, `flush0()` and `flushAndClose()`methods of `StreamHandler` > we read multiple times from volatile writer. The access number can be reduced > by reading the field into local variable once. This pull request has

RFR: 8313768: Reduce interaction with volatile field in j.u.l.StreamHandler

2023-08-04 Thread Sergey Tsypanov
In `publish0()`, `flush0()` and `flushAndClose()`methods of `StreamHandler` we read multiple times from volatile writer. The access number can be reduced by reading the field into local variable once. - Commit messages: - 8313768: Reduce interaction with volatile field in j.u.l.Str

Re: RFR: 6478546: FileInputStream.read() throws OutOfMemoryError when there is plenty available [v2]

2023-07-27 Thread Sergey Tsypanov
On Thu, 27 Jul 2023 16:59:58 GMT, Brian Burkhalter wrote: >> Then I guess we don't need this `if`-clause > > Then I think one gets an error if `0 < len < BUF_SIZE`: > > > $ cat free.c > #include > > int main(int argc, char** argv) > { > char stackBuf[8]; > char* buf; > > buf = st

Re: RFR: 6478546: FileInputStream.read() throws OutOfMemoryError when there is plenty available [v2]

2023-07-27 Thread Sergey Tsypanov
On Thu, 27 Jul 2023 15:54:30 GMT, Brian Burkhalter wrote: >> src/java.base/share/native/libjava/io_util.c line 199: >> >>> 197: } >>> 198: >>> 199: if (buf != stackBuf) >> >> Wouldn't this cause a leak when if-condition is not met and `free(buf)` is >> not called? > > I don't see how

Re: RFR: 6478546: FileInputStream.read() throws OutOfMemoryError when there is plenty available [v2]

2023-07-27 Thread Sergey Tsypanov
On Tue, 25 Jul 2023 23:50:07 GMT, Brian Burkhalter wrote: >> Limit native memory allocation and move write loop from the native layer >> into Java. This change should make the OOME reported in the issue much less >> likely. > > Brian Burkhalter has updated the pull request incrementally with th

Integrated: 8310530: PipedOutputStream.flush() accesses sink racily

2023-07-24 Thread Sergey Tsypanov
On Wed, 21 Jun 2023 14:01:33 GMT, Sergey Tsypanov wrote: > Just a tiny clean-up to remove racy read within synchronized method This pull request has now been integrated. Changeset: d8f2e9ae Author: Sergey Tsypanov Committer: Brian Burkhalter URL: https://git.openjdk.org/jdk/com

Withdrawn: 8311030: ResourceBundle.handleKeySet() is racy

2023-07-03 Thread Sergey Tsypanov
On Wed, 28 Jun 2023 11:05:11 GMT, Sergey Tsypanov wrote: > Double-checked locking should rely on local variable to avoid racy reads from > volatile field. This pull request has been closed without being integrated. - PR: https://git.openjdk.org/jdk/pull/14692

Re: RFR: 8311178: JMH tests don't scale well when sharing output buffers

2023-07-01 Thread Sergey Tsypanov
On Sat, 1 Jul 2023 07:53:17 GMT, Swati Sharma wrote: > The below benchmark files have scaling issues due to cache contention and > leads to poor scaling when run on multiple threads. The patch sets the scope > from benchmark level to thread level to fix the issue: > - org/openjdk/bench/java/io/

Re: RFR: 8311030: ResourceBundle.handleKeySet() is racy

2023-06-30 Thread Sergey Tsypanov
On Fri, 30 Jun 2023 08:30:45 GMT, Raffaello Giulietti wrote: > In the end, this PR is not about fixing a race, as the title seems to suggest > (the original code is correct), but to avoid a volatile read, right? Yeah, probably I was wrong in my conclusion. Should I rename the ticket?

Re: RFR: 8311030: ResourceBundle.handleKeySet() is racy

2023-06-29 Thread Sergey Tsypanov
On Thu, 29 Jun 2023 12:23:11 GMT, Raffaello Giulietti wrote: >> Double-checked locking should rely on local variable to avoid racy reads >> from volatile field. > > The role of the local `keySet` seems pretty useless. It doesn't save neither > volatile reads nor writes. @rgiulietti `keySet` i

Re: RFR: 8311030: ResourceBundle.handleKeySet() is racy

2023-06-29 Thread Sergey Tsypanov
On Wed, 28 Jun 2023 20:02:58 GMT, Roger Riggs wrote: >> Double-checked locking should rely on local variable to avoid racy reads >> from volatile field. > > Looks ok; was this a tool detected race? @RogerRiggs no tool, just fell into the sources while debugging my application - PR

Re: RFR: 8311030: ResourceBundle.handleKeySet() is racy

2023-06-28 Thread Sergey Tsypanov
On Wed, 28 Jun 2023 11:05:11 GMT, Sergey Tsypanov wrote: > Double-checked locking should rely on local variable to avoid racy reads from > volatile field. It'd be a benign race in case all members of `HashSet` are `final`, but they aren't, so there are no safe public

RFR: 8311030: ResourceBundle.handleKeySet() is racy

2023-06-28 Thread Sergey Tsypanov
Double-checked locking should rely on local variable to avoid racy reads from volatile field. - Commit messages: - 8311030: ResourceBundle.handleKeySet() is racy Changes: https://git.openjdk.org/jdk/pull/14692/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14692&range=00

Integrated: 8301492: Modernize equals() method of ResourceBundle.CacheKey and Bundles.CacheKey

2023-06-26 Thread Sergey Tsypanov
On Tue, 31 Jan 2023 11:40:43 GMT, Sergey Tsypanov wrote: > `ResourceBundle.CacheKey.equals()` and `Bundles.CacheKey.equals()` are quire > outdated. This simple clean-up modernizes them. This pull request has now been integrated. Changeset: 297c7996 Author:Sergey Tsypanov Committer:

Re: RFR: 8301492: Modernize equals() method of ResourceBundle.CacheKey and Bundles.CacheKey [v5]

2023-06-26 Thread Sergey Tsypanov
> `ResourceBundle.CacheKey.equals()` and `Bundles.CacheKey.equals()` are quire > outdated. This simple clean-up modernizes them. Sergey Tsypanov has updated the pull request incrementally with one additional commit since the last revision: 8301492: Revert - Changes:

Re: RFR: 8301492: Modernize equals() method of ResourceBundle.CacheKey and Bundles.CacheKey [v4]

2023-06-26 Thread Sergey Tsypanov
On Sun, 25 Jun 2023 22:32:34 GMT, Pavel Rappo wrote: >> I'll re-run our CI, and if all good, I'll sponsor this PR. > >> I'll re-run our CI, and if all good, I'll sponsor this PR. > > The CI tests I started have just passed. While this PR is already good, I > wonder if we make it even better. >

Re: RFR: 8301492: Modernize equals() method of ResourceBundle.CacheKey and Bundles.CacheKey [v3]

2023-06-25 Thread Sergey Tsypanov
On Fri, 23 Jun 2023 22:02:22 GMT, Pavel Rappo wrote: >> src/java.base/share/classes/sun/util/resources/Bundles.java line 510: >> >>> 508: return false; >>> 509: } >>> 510: return Objects.equals(locale, otherEntry.locale) >> >> While the propos

Re: RFR: 8301492: Modernize equals() method of ResourceBundle.CacheKey and Bundles.CacheKey [v4]

2023-06-25 Thread Sergey Tsypanov
> `ResourceBundle.CacheKey.equals()` and `Bundles.CacheKey.equals()` are quire > outdated. This simple clean-up modernizes them. Sergey Tsypanov 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: 8301492: Modernize equals() method of ResourceBundle.CacheKey and Bundles.CacheKey [v3]

2023-06-23 Thread Sergey Tsypanov
On Fri, 23 Jun 2023 10:41:49 GMT, Pavel Rappo wrote: >> Sergey Tsypanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Restore logic > > src/java.base/share/classes/java/util/ResourceB

Re: RFR: 8310530: PipedOutputStream.flush() accesses sink racily [v2]

2023-06-23 Thread Sergey Tsypanov
On Thu, 22 Jun 2023 21:00:18 GMT, Roger Riggs wrote: >> Sergey Tsypanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Update src/java.base/share/classes/java/io/PipedOutputStream.java >> >>

Re: RFR: 8301492: Modernize equals() method of ResourceBundle.CacheKey and Bundles.CacheKey [v3]

2023-06-23 Thread Sergey Tsypanov
On Wed, 1 Feb 2023 10:36:12 GMT, Sergey Tsypanov wrote: >> `ResourceBundle.CacheKey.equals()` and `Bundles.CacheKey.equals()` are quire >> outdated. This simple clean-up modernizes them. > > Sergey Tsypanov has updated the pull request incrementally with one > additional

Re: RFR: 8310530: PipedOutputStream.flush() accesses sink racily [v2]

2023-06-22 Thread Sergey Tsypanov
On Thu, 22 Jun 2023 15:45:21 GMT, Brian Burkhalter wrote: >> Sergey Tsypanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Update src/java.base/share/classes/java/io/PipedOutputStream.java >> >>

Re: RFR: 8310530: PipedOutputStream.flush() accesses sink racily [v2]

2023-06-22 Thread Sergey Tsypanov
On Wed, 21 Jun 2023 14:58:35 GMT, Daniel Fuchs wrote: >> On second thought, this is probably not necessary; write to the sink field >> is in another synchronized method, and this method is synchronized already. >> Is the goal here to remove the synchronized on flush? > > Good observation. Remov

Re: RFR: 8310530: PipedOutputStream.flush() accesses sink racily [v2]

2023-06-21 Thread Sergey Tsypanov
> Just a tiny clean-up to remove racy read within synchronized method Sergey Tsypanov has updated the pull request incrementally with one additional commit since the last revision: Update src/java.base/share/classes/java/io/PipedOutputStream.java Co-authored-by: liach <7806

RFR: 8310530: PipedOutputStream.flush() accesses sink racily

2023-06-21 Thread Sergey Tsypanov
Just a tiny clean-up to remove racy read within synchronized method - Commit messages: - 8310530: PipedOutputStream.flush() accesses sink racily Changes: https://git.openjdk.org/jdk/pull/14589/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14589&range=00 Issue: https://bu

Re: RFR: 8309408: Thread.sleep cleanup

2023-06-12 Thread Sergey Tsypanov
On Sun, 4 Jun 2023 11:28:33 GMT, Alan Bateman wrote: > Thread.sleep has had quite a bit of churn recently to support virtual > threads, add sleep(Duration), a JFR event, and the change the underlying > implementation to support sub-millis precision. I think the changes have > settled down now

Re: RFR: 8301492: Modernize equals() method of ResourceBundle.CacheKey and Bundles.CacheKey [v3]

2023-05-25 Thread Sergey Tsypanov
On Wed, 1 Feb 2023 10:36:12 GMT, Sergey Tsypanov wrote: >> `ResourceBundle.CacheKey.equals()` and `Bundles.CacheKey.equals()` are quire >> outdated. This simple clean-up modernizes them. > > Sergey Tsypanov has updated the pull request incrementally with one > additional

Re: RFR: 8305785: Avoid redundant HashMap.containsKey call in java.util.regex

2023-05-15 Thread Sergey Tsypanov
On Mon, 3 Apr 2023 16:58:15 GMT, Andrey Turbanov wrote: > `Pattern.namedGroups` and `Matcher.namedGroups` contains only non-null > values. It means instead of separate `containsKey`+`get` calls, we can use > single `HashMap.get` call and then compare result with null. > Result code is a bit sim

Integrated: 8300818: Reduce complexity of padding with DateTimeFormatter

2023-05-01 Thread Sergey Tsypanov
On Sat, 21 Jan 2023 21:01:48 GMT, Sergey Tsypanov wrote: > Currently it's O(n) - we do `n` shifts of bytes within `StringBuilder`. This > can be reduced to O(1) improving the code like: > > DateTimeFormatter dtf = new DateTimeFormatterBuilder() > .appendLiteral(&quo

Re: RFR: 8301492: Modernize equals() method of ResourceBundle.CacheKey and Bundles.CacheKey [v3]

2023-04-27 Thread Sergey Tsypanov
On Wed, 1 Feb 2023 10:36:12 GMT, Sergey Tsypanov wrote: >> `ResourceBundle.CacheKey.equals()` and `Bundles.CacheKey.equals()` are quire >> outdated. This simple clean-up modernizes them. > > Sergey Tsypanov has updated the pull request incrementally with one > additional

Re: RFR: 8304918: Remove unused decl field from AnnotatedType implementations

2023-04-25 Thread Sergey Tsypanov
On Sat, 25 Mar 2023 05:52:44 GMT, Chen Liang wrote: > In `AnnotatedTypeBaseImpl`, a `decl` field is declared, referring to the > declaration that the AnnotatedType is from. However, this field is not used > anywhere except passing to constructors of other implementations; it's not > used in de

Re: RFR: 8300818: Reduce complexity of padding with DateTimeFormatter [v7]

2023-04-21 Thread Sergey Tsypanov
d(DateTimeFormatter.ISO_DATE) > .toFormatter(); > String text = dtf.format(LocalDateTime.now()); Sergey Tsypanov has updated the pull request incrementally with one additional commit since the last revision: 8300818: One more benchmark - Changes: - all: https:/

Re: RFR: 8300818: Reduce complexity of padding with DateTimeFormatter [v6]

2023-04-20 Thread Sergey Tsypanov
d(DateTimeFormatter.ISO_DATE) > .toFormatter(); > String text = dtf.format(LocalDateTime.now()); Sergey Tsypanov has updated the pull request incrementally with one additional commit since the last revision: 8300818: Remove blank line - Changes: - all: https:/

Re: RFR: 8300818: Reduce complexity of padding with DateTimeFormatter [v2]

2023-04-18 Thread Sergey Tsypanov
On Mon, 17 Apr 2023 15:21:34 GMT, Roger Riggs wrote: >> @RogerRiggs sorry I don't get it. Maybe you mean speacial casing for >> `padWidth - len`? > > Yes, I meant on the length of the inserted padding. Done - PR Review Comment: https://git.openjdk.org/jdk/pull/12131#discussion_r11

Re: RFR: 8300818: Reduce complexity of padding with DateTimeFormatter [v4]

2023-04-18 Thread Sergey Tsypanov
On Sun, 16 Apr 2023 11:20:46 GMT, Sergey Tsypanov wrote: >> Currently it's O(n) - we do `n` shifts of bytes within `StringBuilder`. This >> can be reduced to O(1) improving the code like: >> >> DateTimeFormatter dtf = new DateTimeFormatterBuilder() >> .appe

Re: RFR: 8300818: Reduce complexity of padding with DateTimeFormatter [v5]

2023-04-18 Thread Sergey Tsypanov
d(DateTimeFormatter.ISO_DATE) > .toFormatter(); > String text = dtf.format(LocalDateTime.now()); Sergey Tsypanov has updated the pull request incrementally with one additional commit since the last revision: 8300818: special cases - Changes: - all: https:/

Re: RFR: 8300818: Reduce complexity of padding with DateTimeFormatter [v2]

2023-04-16 Thread Sergey Tsypanov
On Wed, 12 Apr 2023 17:41:58 GMT, Roger Riggs wrote: >> Added benchmark for this > > Special casing for len == 0 and keeping the existing buf.insert for len == 1 > would avoid object creation except when it would improve performance. @RogerRiggs sorry I don't get it. Maybe you mean speacial cas

Re: RFR: 8300818: Reduce complexity of padding with DateTimeFormatter [v4]

2023-04-16 Thread Sergey Tsypanov
d(DateTimeFormatter.ISO_DATE) > .toFormatter(); > String text = dtf.format(LocalDateTime.now()); Sergey Tsypanov has updated the pull request incrementally with one additional commit since the last revision: 8300818: Extract separate benchmark - Changes: - all: https:/

Re: RFR: 8300818: Reduce complexity of padding with DateTimeFormatter [v3]

2023-04-16 Thread Sergey Tsypanov
On Wed, 12 Apr 2023 17:39:16 GMT, Roger Riggs wrote: >> Sergey Tsypanov 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 conta

Re: RFR: 8305785: Avoid redundant HashMap.containsKey call in java.util.regex

2023-04-16 Thread Sergey Tsypanov
On Mon, 3 Apr 2023 16:58:15 GMT, Andrey Turbanov wrote: > `Pattern.namedGroups` and `Matcher.namedGroups` contains only non-null > values. It means instead of separate `containsKey`+`get` calls, we can use > single `HashMap.get` call and then compare result with null. > Result code is a bit sim

Re: RFR: 8300818: Reduce complexity of padding with DateTimeFormatter [v2]

2023-04-10 Thread Sergey Tsypanov
On Mon, 13 Mar 2023 19:24:38 GMT, Roger Riggs wrote: >> Sergey Tsypanov 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 conta

Re: RFR: 8300818: Reduce complexity of padding with DateTimeFormatter [v3]

2023-04-10 Thread Sergey Tsypanov
d(DateTimeFormatter.ISO_DATE) > .toFormatter(); > String text = dtf.format(LocalDateTime.now()); Sergey Tsypanov 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 req

Integrated: 8304745: Lazily initialize byte[] in java.io.BufferedInputStream

2023-04-06 Thread Sergey Tsypanov
On Wed, 22 Mar 2023 20:34:08 GMT, Sergey Tsypanov wrote: > By default `BufferedInputStream` is constructed with internal buffer with > capacity 8192. In some cases this buffer is never used, e.g. when we call > `IS.readNBytes()` or `IS.readAllBytes()` (relying on `BIS.read1()`

Re: RFR: 8304745: Lazily initialize byte[] in java.io.BufferedInputStream [v10]

2023-04-06 Thread Sergey Tsypanov
> By default `BufferedInputStream` is constructed with internal buffer with > capacity 8192. In some cases this buffer is never used, e.g. when we call > `IS.readNBytes()` or `IS.readAllBytes()` (relying on `BIS.read1()`) or when > `BufferedInputStream` is cascaded. Sergey Tsypanov

Re: RFR: 8304745: Lazily initialize byte[] in java.io.BufferedInputStream [v9]

2023-04-06 Thread Sergey Tsypanov
On Thu, 6 Apr 2023 09:23:33 GMT, Jaikiran Pai wrote: > For this change, I think a benchmark isn't necessary - what would it test, > how quickly a new BufferedInputStream returns as compared to previous code? @jaikiran first of all it demonstrates reducing allocation for plain/cascaded readAll

Re: RFR: JDK-8304945: StringBuilder and StringBuffer should implement Appendable explicitly

2023-04-03 Thread Sergey Tsypanov
On Sat, 1 Apr 2023 17:34:37 GMT, Joe Darcy wrote: > The StringBuilder and StringBuffer classes are Appendable by virtue of from > subclasses their non-public superclass AbstractStringBuilder. > > It is slightly clearer to declare StringBuilder and StringBuffer to directly > implement Appendabl

Integrated: 8304976: Optimize DateTimeFormatterBuilder.ZoneTextPrinterParser.getTree()

2023-03-29 Thread Sergey Tsypanov
On Fri, 17 Feb 2023 09:50:16 GMT, Sergey Tsypanov wrote: > 1) When `DateTimeFormatter` is reused we don't need to copy > `availableZoneIds` and allocate `nonRegionIds` as PrefixTree can be taken > from cache. In the related benchmark allocation of `HashSet` takes ~93% of

  1   2   3   >