RFR: 8267840: Improve URLStreamHandler.parseURL()
There is an optimization opportunity for the widespread use-case when a resource is read from classpath using `getClass().getClassLoader().getResource()` or `getClass().getClassLoader().getResourceAsStream()`. Pay attention to lines starting from 261. In case I run something like var props = getClass().getClassLoader().getResource("/application.properties"); I get into the if-else block starting from 251 and here 'separator' variable is an empty String. In this case we can skip 'separator' from concatenation chain and use `String.concat()` as there are only two items concatenated. In the opposite case `separator` variable is `"/"` and at the same time `ind` variable is `-1`. This means that expression `path.substring(0, ind + 1)` always returns an empty String and again can be excluded from concatenation chain allowing usage of `String.concat()` which allows to dodge utilization of `StringBuilder` (here `StringConcatFactory` is not available, see https://github.com/openjdk/jdk/pull/3627) In the next else-block, starting from 274, again, `String.concat()` is applicable. In another if-else block, starting from 277, when id is 0 again path.substring(0, ind) returns empty String making concatenation pointless and avoidable. There are also some other minor clean-ups possible regarding constant conditions (lines 252 and 161). The change allows to reduce significantly resource look-up costs for a very wide-spread case: @State(Scope.Benchmark) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Fork(jvmArgsAppend = {"-Xms2g", "-Xmx2g"}) public class ClassGetResourceBenchmark { private final Class clazz = getClass(); @Benchmark public URL getResource() { return clazz.getResource("/application.properties"); } } The change allows to reduce memory consumption significantly: before Benchmark Mode Cnt Score Error Units ClassGetResourceBenchmark.getResource avgt 100 1649,367 ± 5,904 ns/op ClassGetResourceBenchmark.getResource:·gc.alloc.rateavgt 100 619,204 ± 2,413 MB/sec ClassGetResourceBenchmark.getResource:·gc.alloc.rate.norm avgt 100 1339,232 ± 4,909B/op ClassGetResourceBenchmark.getResource:·gc.churn.G1_Eden_Space avgt 100 627,192 ± 74,972 MB/sec ClassGetResourceBenchmark.getResource:·gc.churn.G1_Eden_Space.norm avgt 100 1356,681 ± 162,354B/op ClassGetResourceBenchmark.getResource:·gc.churn.G1_Survivor_Space avgt 100 0,119 ± 0,100 MB/sec ClassGetResourceBenchmark.getResource:·gc.churn.G1_Survivor_Space.norm avgt 100 0,257 ± 0,217B/op ClassGetResourceBenchmark.getResource:·gc.count avgt 100 128,000counts ClassGetResourceBenchmark.getResource:·gc.time avgt 100 227,000ms after Benchmark Mode Cnt Score Error Units ClassGetResourceBenchmark.getResource avgt 100 1599,948 ± 4,115 ns/op ClassGetResourceBenchmark.getResource:·gc.alloc.rateavgt 100 358,434 ± 0,922 MB/sec ClassGetResourceBenchmark.getResource:·gc.alloc.rate.norm avgt 100 752,016 ± 0,004B/op ClassGetResourceBenchmark.getResource:·gc.churn.G1_Eden_Space avgt 100 342,778 ± 76,490 MB/sec ClassGetResourceBenchmark.getResource:·gc.churn.G1_Eden_Space.norm avgt 100 719,264 ± 160,513B/op ClassGetResourceBenchmark.getResource:·gc.churn.G1_Survivor_Space avgt 100 0,008 ± 0,005 MB/sec ClassGetResourceBenchmark.getResource:·gc.churn.G1_Survivor_Space.norm avgt 100 0,017 ± 0,010B/op ClassGetResourceBenchmark.getResource:·gc.count avgt 10070,000counts ClassGetResourceBenchmark.getResource:·gc.time avgt 100 151,000ms - Commit messages: - 8267840: Improve URLStreamHandler.parseURL() Changes: https://git.openjdk.java.net/jdk/pull/4526/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=4526&range=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8267840 Stats: 25 lines in 1 file changed: 3 ins; 8 del; 14 mod Patch: https://git.openjdk.java.net/jdk/pull/4526.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/4526/head:pull/4526 PR: https://git.openjdk.java.net/jdk/pull/4526
Re: [jdk17] RFR: JDK-8265369 [macos-aarch64] java/net/MulticastSocket/Promiscuous.java failed with "SocketException: Cannot allocate memory" [v3]
On Thu, 17 Jun 2021 21:31:48 GMT, Mark Sheppard wrote: >> JDK-8265369 [macos-aarch64] java/net/MulticastSocket/Promiscuous.java failed >> with "SocketException: Cannot allocate memory" >> >> The test java/net/MulticastSocket/Promiscuous.java has been observed to fail >> on a regular basis on macosx-aarch. >> This is typically under heavy test load on a test machine. Analysis of the >> problem have >> shown that the setsockopt for joining a multicast group will intermittently >> fail with ENOMEM. >> >> While analysis of test environment shows significant memory usage and some >> memory pressure, it is >> not excessive and as such it is deemed transition or temporary condition, >> such that a retry of the >> setsockopt system call, has been seen to mitigate the issue. This adds to >> the stability of the >> Promiscuous.java test and reduces test failure noise. >> >> The proposed fix is in >> open/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c >> in the mcast_join_leave function. That is, if setsockopt to join an mcast >> group fails, and the errno == ENOMEM, >> then re-invoke the setsockopt system call for joining a mcast group. >> The change has been applied as a conditional compilation. >> Additionally this change result in the Promiscuous.java test being removed >> from the >> ProblemList.txt. >> >> Please oblige and review the changes for a fix of the issue JDK-8265369 > > Mark Sheppard has updated the pull request incrementally with one additional > commit since the last revision: > > JDK-8265369 [macos-aarch64] java/net/MulticastSocket/Promiscuous.java > failed with "SocketException: Cannot allocate memory" > remove #ifdef __APPLE__ from int res; declaration, remove space and fix > indentation (as per comments from CH and M3) Marked as reviewed by michaelm (Reviewer). - PR: https://git.openjdk.java.net/jdk17/pull/44
Re: [jdk17] RFR: JDK-8265369 [macos-aarch64] java/net/MulticastSocket/Promiscuous.java failed with "SocketException: Cannot allocate memory" [v3]
On Thu, 17 Jun 2021 21:31:48 GMT, Mark Sheppard wrote: >> JDK-8265369 [macos-aarch64] java/net/MulticastSocket/Promiscuous.java failed >> with "SocketException: Cannot allocate memory" >> >> The test java/net/MulticastSocket/Promiscuous.java has been observed to fail >> on a regular basis on macosx-aarch. >> This is typically under heavy test load on a test machine. Analysis of the >> problem have >> shown that the setsockopt for joining a multicast group will intermittently >> fail with ENOMEM. >> >> While analysis of test environment shows significant memory usage and some >> memory pressure, it is >> not excessive and as such it is deemed transition or temporary condition, >> such that a retry of the >> setsockopt system call, has been seen to mitigate the issue. This adds to >> the stability of the >> Promiscuous.java test and reduces test failure noise. >> >> The proposed fix is in >> open/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c >> in the mcast_join_leave function. That is, if setsockopt to join an mcast >> group fails, and the errno == ENOMEM, >> then re-invoke the setsockopt system call for joining a mcast group. >> The change has been applied as a conditional compilation. >> Additionally this change result in the Promiscuous.java test being removed >> from the >> ProblemList.txt. >> >> Please oblige and review the changes for a fix of the issue JDK-8265369 > > Mark Sheppard has updated the pull request incrementally with one additional > commit since the last revision: > > JDK-8265369 [macos-aarch64] java/net/MulticastSocket/Promiscuous.java > failed with "SocketException: Cannot allocate memory" > remove #ifdef __APPLE__ from int res; declaration, remove space and fix > indentation (as per comments from CH and M3) Marked as reviewed by chegar (Reviewer). - PR: https://git.openjdk.java.net/jdk17/pull/44
Re: [jdk17] RFR: JDK-8265369 [macos-aarch64] java/net/MulticastSocket/Promiscuous.java failed with "SocketException: Cannot allocate memory" [v3]
On Thu, 17 Jun 2021 21:31:48 GMT, Mark Sheppard wrote: >> JDK-8265369 [macos-aarch64] java/net/MulticastSocket/Promiscuous.java failed >> with "SocketException: Cannot allocate memory" >> >> The test java/net/MulticastSocket/Promiscuous.java has been observed to fail >> on a regular basis on macosx-aarch. >> This is typically under heavy test load on a test machine. Analysis of the >> problem have >> shown that the setsockopt for joining a multicast group will intermittently >> fail with ENOMEM. >> >> While analysis of test environment shows significant memory usage and some >> memory pressure, it is >> not excessive and as such it is deemed transition or temporary condition, >> such that a retry of the >> setsockopt system call, has been seen to mitigate the issue. This adds to >> the stability of the >> Promiscuous.java test and reduces test failure noise. >> >> The proposed fix is in >> open/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c >> in the mcast_join_leave function. That is, if setsockopt to join an mcast >> group fails, and the errno == ENOMEM, >> then re-invoke the setsockopt system call for joining a mcast group. >> The change has been applied as a conditional compilation. >> Additionally this change result in the Promiscuous.java test being removed >> from the >> ProblemList.txt. >> >> Please oblige and review the changes for a fix of the issue JDK-8265369 > > Mark Sheppard has updated the pull request incrementally with one additional > commit since the last revision: > > JDK-8265369 [macos-aarch64] java/net/MulticastSocket/Promiscuous.java > failed with "SocketException: Cannot allocate memory" > remove #ifdef __APPLE__ from int res; declaration, remove space and fix > indentation (as per comments from CH and M3) Marked as reviewed by dfuchs (Reviewer). - PR: https://git.openjdk.java.net/jdk17/pull/44
Re: RFR: JDK-8268464 : Remove dependancy of TestHttpsServer, HttpTransaction, HttpCallback from open/test/jdk/sun/net/www/protocol/https/ tests [v4]
On Thu, 17 Jun 2021 16:23:08 GMT, Mahendra Chhipa wrote: >> …HttpCallback from open/test/jdk/sun/net/www/protocol/https/ tests > > Mahendra Chhipa has updated the pull request incrementally with one > additional commit since the last revision: > > Implemented review comments Marked as reviewed by dfuchs (Reviewer). - PR: https://git.openjdk.java.net/jdk/pull/4432
Integrated: 8268900: com/sun/net/httpserver/Headers.java: Fix indentation and whitespace
On Thu, 17 Jun 2021 09:17:24 GMT, Julia Boes wrote: > This cleanup-only change fixes the indentation of all members from 8 to 4 > spaces and removes whitespace in method invocations (example: `foo ()` -> > `foo()`). It also removes superfluous type parameters on lines 83, 168, 206. This pull request has now been integrated. Changeset: f4d20b21 Author:Julia Boes URL: https://git.openjdk.java.net/jdk/commit/f4d20b215eb3c90ca28bf973e7614486226692b5 Stats: 163 lines in 1 file changed: 32 ins; 33 del; 98 mod 8268900: com/sun/net/httpserver/Headers.java: Fix indentation and whitespace Reviewed-by: dfuchs, chegar, michaelm - PR: https://git.openjdk.java.net/jdk/pull/4517
[jdk17] Integrated: JDK-8265369 [macos-aarch64] java/net/MulticastSocket/Promiscuous.java failed with "SocketException: Cannot allocate memory"
On Mon, 14 Jun 2021 15:28:01 GMT, Mark Sheppard wrote: > JDK-8265369 [macos-aarch64] java/net/MulticastSocket/Promiscuous.java failed > with "SocketException: Cannot allocate memory" > > The test java/net/MulticastSocket/Promiscuous.java has been observed to fail > on a regular basis on macosx-aarch. > This is typically under heavy test load on a test machine. Analysis of the > problem have > shown that the setsockopt for joining a multicast group will intermittently > fail with ENOMEM. > > While analysis of test environment shows significant memory usage and some > memory pressure, it is > not excessive and as such it is deemed transition or temporary condition, > such that a retry of the > setsockopt system call, has been seen to mitigate the issue. This adds to the > stability of the > Promiscuous.java test and reduces test failure noise. > > The proposed fix is in > open/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c > in the mcast_join_leave function. That is, if setsockopt to join an mcast > group fails, and the errno == ENOMEM, > then re-invoke the setsockopt system call for joining a mcast group. > The change has been applied as a conditional compilation. > Additionally this change result in the Promiscuous.java test being removed > from the > ProblemList.txt. > > Please oblige and review the changes for a fix of the issue JDK-8265369 This pull request has now been integrated. Changeset: d8a0582a Author:Mark Sheppard URL: https://git.openjdk.java.net/jdk17/commit/d8a0582a36340bcc65910f3a34132ec6e04e5d01 Stats: 22 lines in 2 files changed: 16 ins; 1 del; 5 mod 8265369: [macos-aarch64] java/net/MulticastSocket/Promiscuous.java failed with "SocketException: Cannot allocate memory" Reviewed-by: dfuchs, michaelm, chegar - PR: https://git.openjdk.java.net/jdk17/pull/44
RFR: 8268960: com/sun/net/httpserver/Headers.java: Ensure all mutator methods normalize keys
`com.sun.net.httpserver.Headers` normalizes its keys to adhere to the following format: First character uppercase, all other characters lowercase, for example `"foo" -> "Foo"`. This behaviour is not consistent across the mutator methods of the class, in particular `putAll()` and `replaceAll()` do not apply normalization. The suggested fix is to update the implementation of `putAll()` and to add an implementation of of the java.util.Map default method `replaceAll()`. While here, we can improve `equals()` by adding a type check and add a `toString()` implementation. - Commit messages: - add toString - Merge branch master - initial commit Changes: https://git.openjdk.java.net/jdk/pull/4528/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=4528&range=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8268960 Stats: 119 lines in 2 files changed: 113 ins; 0 del; 6 mod Patch: https://git.openjdk.java.net/jdk/pull/4528.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/4528/head:pull/4528 PR: https://git.openjdk.java.net/jdk/pull/4528
RFR: Merge jdk17
Forwardport JDK 17 -> JDK 18 - Commit messages: - Merge - 8268316: Typo in JFR jdk.Deserialization event - 8268638: semaphores of AsyncLogWriter may be broken when JVM is exiting. - 8264775: ClhsdbFindPC still fails with java.lang.RuntimeException: 'In java stack' missing from stdout/stderr - 8265073: XML transformation and indentation when using xml:space - 8269025: jsig/Testjsig.java doesn't check exit code - 8266518: Refactor and expand scatter/gather tests - 8268903: JFR: RecordingStream::dump is missing @since - 8265369: [macos-aarch64] java/net/MulticastSocket/Promiscuous.java failed with "SocketException: Cannot allocate memory" - 8268564: mark hotspot serviceability/attach tests which ignore external VM flags - ... and 13 more: https://git.openjdk.java.net/jdk/compare/8f2456e5...ed622f4b The merge commit only contains trivial merges, so no merge-specific webrevs have been generated. Changes: https://git.openjdk.java.net/jdk/pull/4533/files Stats: 12229 lines in 119 files changed: 6768 ins; 5337 del; 124 mod Patch: https://git.openjdk.java.net/jdk/pull/4533.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/4533/head:pull/4533 PR: https://git.openjdk.java.net/jdk/pull/4533
Re: RFR: Merge jdk17 [v2]
> Forwardport JDK 17 -> JDK 18 Jesper Wilhelmsson has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 46 commits: - Merge - 8267042: bug in monitor locking/unlocking on ARM32 C1 due to uninitialized BasicObjectLock::_displaced_header Co-authored-by: Chris Cole Reviewed-by: dsamersoff - 8268964: Remove unused ReferenceProcessorAtomicMutator Reviewed-by: tschatzl, pliden - 8268900: com/sun/net/httpserver/Headers.java: Fix indentation and whitespace Reviewed-by: dfuchs, chegar, michaelm - Merge - 8268678: LetsEncryptCA.java test fails as Let’s Encrypt Authority X3 is retired Reviewed-by: xuelei - 8267189: Remove duplicated unregistered classes from dynamic archive Reviewed-by: ccheung, minqi - 8268638: semaphores of AsyncLogWriter may be broken when JVM is exiting. Reviewed-by: dholmes, phh - 8268556: Use bitmap for storing regions that failed evacuation Reviewed-by: kbarrett, iwalulya, sjohanss - 8268294: Reusing HttpClient in a WebSocket.Listener hangs. Reviewed-by: dfuchs - ... and 36 more: https://git.openjdk.java.net/jdk/compare/b8f073be...ed622f4b - Changes: https://git.openjdk.java.net/jdk/pull/4533/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=4533&range=01 Stats: 8681 lines in 159 files changed: 7992 ins; 386 del; 303 mod Patch: https://git.openjdk.java.net/jdk/pull/4533.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/4533/head:pull/4533 PR: https://git.openjdk.java.net/jdk/pull/4533
Integrated: Merge jdk17
On Fri, 18 Jun 2021 22:17:41 GMT, Jesper Wilhelmsson wrote: > Forwardport JDK 17 -> JDK 18 This pull request has now been integrated. Changeset: b7d78a5b Author:Jesper Wilhelmsson URL: https://git.openjdk.java.net/jdk/commit/b7d78a5b661e2b00f271298db3b6cc873cf754e7 Stats: 12229 lines in 119 files changed: 6768 ins; 5337 del; 124 mod Merge - PR: https://git.openjdk.java.net/jdk/pull/4533