RFR: 8309665: Simplify Arrays.copyOf/-Range methods

2023-06-08 Thread Claes Redestad
https://bugs.openjdk.org/browse/JDK-8301958 and later changes improved Arrays.copyOf/-Range methods to improve peak performance in microbenchmarks when copying the entire array, but it's resulted in a few lurking footprint benchmark issues that come down to incurring slightly more JIT activity.

Re: RFR: 8302822: Method/Field/Constructor/RecordComponent::getGenericInfo() is not thread safe

2023-06-01 Thread Claes Redestad
On Mon, 20 Feb 2023 17:03:33 GMT, Peter Levart wrote: >> We don't fear calling the factory twice for benign races, as the distinct >> constructor factory instances are behaviorally the same. >> >> The true issue lies in the double getfield operations: Java memory model >> doesn't require the

Re: RFR: 8132995: Matcher$ImmutableMatchResult should be optimized to reduce space usage [v3]

2023-05-17 Thread Claes Redestad
On Wed, 17 May 2023 09:19:10 GMT, Raffaello Giulietti wrote: >> When appropriate and useful, copies only the relevant portion of the >> `CharSequence` to the match result. > > Raffaello Giulietti has updated the pull request with a new target base due > to a merge or a rebase. The incremental

Re: RFR: 8307483: New micros for j.u.c.LockSupport [v3]

2023-05-17 Thread Claes Redestad
On Tue, 9 May 2023 19:13:42 GMT, Eric Caspole wrote: >> These micros were developed while investigating JDK-8305670 by myself and >> Sergey Kuksenko. The order of thread creation was important in that bug, so >> there are 2 JMH for creating sleepers before and after the worker threads. > >

Re: RFR: 8306842: Classfile API performance improvements [v7]

2023-05-16 Thread Claes Redestad
On Tue, 16 May 2023 15:17:13 GMT, Chen Liang wrote: >> src/java.base/share/classes/jdk/internal/classfile/impl/StackMapDecoder.java >> line 83: >> >>> 81: vtis = new >>> VerificationTypeInfo[methodType.parameterCount()]; >>> 82: } >>> 83: for(var arg :

Re: RFR: 8306842: Classfile API performance improvements [v7]

2023-05-16 Thread Claes Redestad
On Tue, 16 May 2023 08:17:02 GMT, Adam Sotona wrote: >> Following improvements implemented: >> - Switch over `String` replaced with switch single char >> - Binary search for frames in `StackMapGenerator` >> - `StackMapGenerator.rawHandlers` with pre-calculated offsets >> - `ClassEntry` is

Re: RFR: 8132995: Matcher$ImmutableMatchResult should be optimized to reduce space usage [v2]

2023-05-16 Thread Claes Redestad
On Thu, 11 May 2023 09:22:44 GMT, Raffaello Giulietti wrote: >> When appropriate and useful, copies only the relevant portion of the >> `CharSequence` to the match result. > > Raffaello Giulietti has updated the pull request incrementally with one > additional commit since the last revision:

Re: RFR: 8306842: Classfile API performance improvements [v4]

2023-05-15 Thread Claes Redestad
On Mon, 15 May 2023 14:34:13 GMT, Adam Sotona wrote: >> I have to side with @liach here: `LinkedList` iteration is significantly >> slower than `ArrayList` even though the computational complexity is >> identical. Often by an integer factor. This is due to the sparseness of the >> linked list

Re: RFR: 8306842: Classfile API performance improvements [v4]

2023-05-15 Thread Claes Redestad
On Fri, 12 May 2023 13:19:44 GMT, Chen Liang wrote: >> Adam Sotona has updated the pull request incrementally with one additional >> commit since the last revision: >> >> fixed jmh benchmark parameters > > test/micro/org/openjdk/bench/jdk/classfile/RebuildMethodBodies.java line 57: > >> 55:

Re: RFR: 8306842: Classfile API performance improvements [v4]

2023-05-10 Thread Claes Redestad
On Wed, 10 May 2023 09:55:13 GMT, Adam Sotona wrote: >> That seems misplaced. Please file an RFE to have this cleaned up. >> >> Each microbenchmark that has to add opens needs to take responsibility for >> that themselves and not change the environment for everything else. And all >> micros

Re: RFR: 8306842: Classfile API performance improvements [v3]

2023-05-09 Thread Claes Redestad
On Tue, 9 May 2023 16:08:57 GMT, Chen Liang wrote: >> To make this runnable without manually adding a bunch of `--add-opens` flags > > They are added in the `make/RunTests.gmk`: >

Re: RFR: 8306842: Classfile API performance improvements [v3]

2023-05-09 Thread Claes Redestad
On Tue, 9 May 2023 16:09:14 GMT, Adam Sotona wrote: >> Following improvements implemented: >> - Switch over `String` replaced with switch single char >> - Binary search for frames in `StackMapGenerator` >> - `StackMapGenerator.rawHandlers` with pre-calculated offsets >> - `ClassEntry` is caching

Re: RFR: 8306842: Classfile API performance improvements [v3]

2023-05-09 Thread Claes Redestad
On Tue, 9 May 2023 15:50:30 GMT, Claes Redestad wrote: >> Adam Sotona has updated the pull request incrementally with one additional >> commit since the last revision: >> >> fixed StackMapGenerator > > test/micro/org/openjdk/bench/jdk/classfile/RebuildMetho

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

2023-04-21 Thread Claes Redestad
On Fri, 21 Apr 2023 17:45:50 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("Date:") >>

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

2023-04-21 Thread Claes Redestad
On Thu, 20 Apr 2023 15:05:18 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("Date:") >>

Re: RFR: 8306075: Micro-optimize Enum.hashCode [v2]

2023-04-17 Thread Claes Redestad
On Mon, 17 Apr 2023 13:27:43 GMT, olivergillespie wrote: > > Why isn't `Enum::hashCode` simply doing `return ordinal;`? > > See https://bugs.openjdk.org/browse/JDK-8050217 Thanks! If there are apps where `Enum::hashCode` is performance sensitive then run-to-run stability may be a stronger

Re: RFR: 8306075: Micro-optimize Enum.hashCode [v3]

2023-04-17 Thread Claes Redestad
On Mon, 17 Apr 2023 13:27:43 GMT, olivergillespie wrote: >> Improve the speed of Enum.hashCode by caching the identity hashcode on first >> use. I've seen an application where Enum.hashCode is a hot path, and this is >> fairly simple speedup. The memory overhead is low; in enums with no extra

Re: RFR: 8306075: Micro-optimize Enum.hashCode [v2]

2023-04-17 Thread Claes Redestad
On Mon, 17 Apr 2023 13:23:35 GMT, olivergillespie wrote: >> Improve the speed of Enum.hashCode by caching the identity hashcode on first >> use. I've seen an application where Enum.hashCode is a hot path, and this is >> fairly simple speedup. The memory overhead is low; in enums with no extra

Re: RFR: JDK-8302323 Add repeat methods to StringBuilder/StringBuffer [v10]

2023-03-28 Thread Claes Redestad
On Mon, 27 Mar 2023 18:37:12 GMT, Jim Laskey wrote: >> Add the ability to repeatedly append char and CharSequence data to >> StringBuilder/StringBuffer. > > Jim Laskey has updated the pull request incrementally with one additional > commit since the last revision: > > Use Arrays.fill Looks

Re: RFR: JDK-8302323 Add repeat methods to StringBuilder/StringBuffer [v10]

2023-03-28 Thread Claes Redestad
On Mon, 27 Mar 2023 18:37:12 GMT, Jim Laskey wrote: >> Add the ability to repeatedly append char and CharSequence data to >> StringBuilder/StringBuffer. > > Jim Laskey has updated the pull request incrementally with one additional > commit since the last revision: > > Use Arrays.fill

Re: RFR: 8302818: Optimize wrapper sets and immutable sets of Enums [v5]

2023-03-21 Thread Claes Redestad
On Tue, 21 Feb 2023 03:39:46 GMT, Tingjun Yuan wrote: >> Currently, the two subclasses of `java.util.EnumSet` optimize bulk >> operations when the argument is also a `EnumSet`, but there is no such >> optimization for wrapper sets (returned by `Collections.unmodifiableSet`, >>

Re: RFR: 8302818: Optimize wrapper sets and immutable sets of Enums [v5]

2023-03-21 Thread Claes Redestad
On Tue, 21 Feb 2023 03:39:46 GMT, Tingjun Yuan wrote: >> Currently, the two subclasses of `java.util.EnumSet` optimize bulk >> operations when the argument is also a `EnumSet`, but there is no such >> optimization for wrapper sets (returned by `Collections.unmodifiableSet`, >>

Re: RFR: 8304245: Speed up CharacterData.of by avoiding bit shifting in the latin1 fast-path test

2023-03-15 Thread Claes Redestad
On Wed, 15 Mar 2023 12:07:12 GMT, Sergey Tsypanov wrote: >> src/java.base/share/classes/java/lang/CharacterData.java line 72: >> >>> 70: >>> 71: static final CharacterData of(int ch) { >>> 72: if (ch >= 0 && ch <= 0xFF) { // fast-path >> >> Maybereducing to a single branch

Re: RFR: 8304245: Speed up CharacterData.of by avoiding bit shifting in the latin1 fast-path test

2023-03-15 Thread Claes Redestad
On Wed, 15 Mar 2023 11:26:21 GMT, Eirik Bjorsnos wrote: > By avoiding a bit shift operation for the latin1 fast-path test, we can speed > up the `java.lang.CharacterData.of` method by ~25% for latin1 code points. > > The latin1 test is currently implemented as `ch >>> 8 == 0`. We can replace

Re: RFR: JDK-8302323 Add repeat methods to StringBuilder/StringBuffer [v8]

2023-03-14 Thread Claes Redestad
On Fri, 3 Mar 2023 19:04:22 GMT, Jim Laskey wrote: >> Add the ability to repeatedly append char and CharSequence data to >> StringBuilder/StringBuffer. > > Jim Laskey has updated the pull request incrementally with one additional > commit since the last revision: > > Expand test for

Re: RFR: 8303480: Miscellaneous fixes to mostly invisible doc comments

2023-03-03 Thread Claes Redestad
s >> >> I assume “iff” should “if”? > > Here and elsewhere in this file "iff" might mean [if and only > if](https://en.wikipedia.org/wiki/If_and_only_if), which would make sense. > (FWIW, there are a few hundred occurrences of the word "iff" in src.) > >

Re: RFR: 8301119: Support for GB18030-2022 [v2]

2023-02-23 Thread Claes Redestad
On Thu, 23 Feb 2023 08:32:29 GMT, Claes Redestad wrote: >> `Charset` class is initialized *before* system properties are set up, in >> order to check the JNU encoding (used for file path name) is a supported >> charset or not. In some OS environments, GB18030 is the native

Re: RFR: 8301119: Support for GB18030-2022 [v2]

2023-02-23 Thread Claes Redestad
On Wed, 22 Feb 2023 17:52:01 GMT, Naoto Sato wrote: >>> curious - what scenario triggers this call at initLevel < 1 ? >> >> It's not supported, but it is possible that someone might run with >> -Dfile.encoding=GB18030, in which case the default charset is used before >> the system properties

Re: RFR: 8302871: Speed up StringLatin1.regionMatchesCI [v10]

2023-02-22 Thread Claes Redestad
On Wed, 22 Feb 2023 07:11:16 GMT, Eirik Bjorsnos wrote: >> This PR suggests we can speed up `StringLatin1.regionMatchesCI` by applying >> 'the oldest ASCII trick in the book'. >> >> The new static method `CharacterDataLatin1.equalsIgnoreCase` compares two >> latin1 bytes for equality ignoring

Integrated: 8302863: Speed up String::encodeASCII using countPositives

2023-02-21 Thread Claes Redestad
On Sat, 18 Feb 2023 23:26:08 GMT, Claes Redestad wrote: > When encoding Strings to US-ASCII we can speed up the happy path > significantly by using `StringCoding.countPositives` as a speculative check > for whether there are any chars that needs to be replaced by `'?'`. Once a &g

Re: RFR: 8302863: Speed up String::encodeASCII using countPositives

2023-02-21 Thread Claes Redestad
On Mon, 20 Feb 2023 21:40:41 GMT, Brett Okken wrote: >> When encoding Strings to US-ASCII we can speed up the happy path >> significantly by using `StringCoding.countPositives` as a speculative check >> for whether there are any chars that needs to be replaced by `'?'`. Once a >> non-ASCII

Re: RFR: 8302871: Speed up StringLatin1.regionMatchesCI [v7]

2023-02-21 Thread Claes Redestad
On Tue, 21 Feb 2023 11:14:13 GMT, Eirik Bjorsnos wrote: >> This PR suggests we can speed up `StringLatin1.regionMatchesCI` by applying >> 'the oldest ASCII trick in the book'. >> >> The new static method `CharacterDataLatin1.equalsIgnoreCase` compares two >> latin1 bytes for equality ignoring

Re: RFR: 8302877: Speed up latin1 case conversions [v2]

2023-02-21 Thread Claes Redestad
On Tue, 21 Feb 2023 06:59:47 GMT, Eirik Bjorsnos wrote: >> This PR suggests we speed up Character.toUpperCase and Character.toLowerCase >> for latin1 code points by applying the 'oldest ASCII trick in the book'. >> >> This takes advantage of the fact that latin1 uppercase code points are >>

Re: RFR: 8302871: Speed up StringLatin1.regionMatchesCI [v4]

2023-02-20 Thread Claes Redestad
On Mon, 20 Feb 2023 16:16:45 GMT, Eirik Bjorsnos wrote: >> src/java.base/share/classes/java/lang/CharacterDataLatin1.java.template line >> 170: >> >>> 168: * @return true if the two bytes are considered equals ignoring >>> case in latin1 >>> 169: */ >>> 170: static boolean

Re: RFR: 8302871: Speed up StringLatin1.regionMatchesCI [v4]

2023-02-20 Thread Claes Redestad
On Mon, 20 Feb 2023 14:45:09 GMT, Eirik Bjorsnos wrote: >> This PR suggests we can speed up `StringLatin1.regionMatchesCI` by applying >> 'the oldest ASCII trick in the book'. >> >> The new static method `CharacterDataLatin1.equalsIgnoreCase` compares two >> latin1 bytes for equality ignoring

Re: Speed up latin1 case folding

2023-02-20 Thread Claes Redestad
RFE filed: https://bugs.openjdk.org/browse/JDK-8302877 /Claes 17 feb. 2023 kl. 18:38 skrev Eirik Bjørsnøs mailto:eir...@gmail.com>>: Hi, The following PR suggests we can speed up Character.toUpperCase and Character.toLowerCase for latin1 code points by applying 'the oldest ASCII trick in

Re: Speed up StringLatin1.regionMatchesCI

2023-02-20 Thread Claes Redestad
RFE filed: https://bugs.openjdk.org/browse/JDK-8302871 /Claes 18 feb. 2023 kl. 10:28 skrev Eirik Bjørsnøs mailto:eir...@gmail.com>>: Hi, The following PR suggests we can speed up StringLatin1.regionMatchesCI by applying 'the oldest ASCII trick in the book':

Re: Speed up StringLatin1.regionMatchesCI_UTF16

2023-02-20 Thread Claes Redestad
RFE filed: https://bugs.openjdk.org/browse/JDK-8302872 /Claes 18 feb. 2023 kl. 19:58 skrev Eirik Bjørsnøs mailto:eir...@gmail.com>>: Hi, This PR continues the effort to speed up case-insensitive string comparisons, this time tackling comparison of latin1-coded strings with utf16-coded

Re: RFR: 8302863: Speed up String::encodeASCII using countPositives

2023-02-20 Thread Claes Redestad
On Sat, 18 Feb 2023 23:26:08 GMT, Claes Redestad wrote: > When encoding Strings to US-ASCII we can speed up the happy path > significantly by using `StringCoding.countPositives` as a speculative check > for whether there are any chars that needs to be replaced by `'?'`. Once a &g

Re: RFR: 8302863: Speed up String::encodeASCII using countPositives

2023-02-20 Thread Claes Redestad
On Sun, 19 Feb 2023 07:24:30 GMT, David Schlosnagle wrote: >> When encoding Strings to US-ASCII we can speed up the happy path >> significantly by using `StringCoding.countPositives` as a speculative check >> for whether there are any chars that needs to be replaced by `'?'`. Once a >>

RFR: 8302863: Speed up String::encodeASCII using countPositives

2023-02-20 Thread Claes Redestad
When encoding Strings to US-ASCII we can speed up the happy path significantly by using `StringCoding.countPositives` as a speculative check for whether there are any chars that needs to be replaced by `'?'`. Once a non-ASCII char is encountered we fall back to the slow loop and replace as

Re: String encodeASCII

2023-02-20 Thread Claes Redestad
doing the copying and checking together rather than as separate loops seems to speed things up considerably, even for happy-path of no failures. Brett On Sat, Feb 18, 2023 at 5:49 PM Claes Redestad mailto:claes.redes...@oracle.com>> wrote: Hi, general comment: String might be one of

Re: RFR: 8302822: Method/Field/Constructor/RecordComponent::getGenericInfo() is not thread safe

2023-02-20 Thread Claes Redestad
On Sun, 19 Feb 2023 18:41:18 GMT, liach wrote: > 8302822: Method/Field/Constructor/RecordComponent::getGenericInfo() is not > thread safe I think of this pattern of reading a to-be-lazily-initialized value into a local as simple hygiene, `volatile` or not. The code might seem solid without

Re: RFR: 8302822: Method/Field/Constructor/RecordComponent::getGenericInfo() is not thread safe

2023-02-20 Thread Claes Redestad
On Sun, 19 Feb 2023 18:41:18 GMT, liach wrote: > 8302822: Method/Field/Constructor/RecordComponent::getGenericInfo() is not > thread safe Marked as reviewed by redestad (Reviewer). - PR: https://git.openjdk.org/jdk/pull/12643

Re: String encodeASCII

2023-02-18 Thread Claes Redestad
Hi, general comment: String might be one of the trickier places to add a VarHandle dependency, since String is used very early in the bootstrap and depended upon by everything else, so I’d expect such a solution would have to navigate potential circularity issues carefully. It’d be good to

Re: RFR: 8302315: Examine cost of clone of primitive arrays compared to arraycopy

2023-02-18 Thread Claes Redestad
On Fri, 17 Feb 2023 09:58:54 GMT, Claes Redestad wrote: > During work on #12453 @schlosna reported that `array.clone()` might > underperform `System.arraycopy` in microbenchmarks and I opted to go with > `arraycopy` throughout while investigating. > > Testing on x86 (Sandy

Integrated: 8302315: Examine cost of clone of primitive arrays compared to arraycopy

2023-02-18 Thread Claes Redestad
On Fri, 17 Feb 2023 09:58:54 GMT, Claes Redestad wrote: > During work on #12453 @schlosna reported that `array.clone()` might > underperform `System.arraycopy` in microbenchmarks and I opted to go with > `arraycopy` throughout while investigating. > > Testing on x86 (Sandy

Re: RFR: 8302315: Examine cost of clone of primitive arrays compared to arraycopy

2023-02-17 Thread Claes Redestad
On Fri, 17 Feb 2023 09:58:54 GMT, Claes Redestad wrote: > During work on #12453 @schlosna reported that `array.clone()` might > underperform `System.arraycopy` in microbenchmarks and I opted to go with > `arraycopy` throughout while investigating. > > Testing on x86 (Sandy

RFR: 8302315: Examine cost of clone of primitive arrays compared to arraycopy

2023-02-17 Thread Claes Redestad
During work on #12453 @schlosna reported that `array.clone()` might underperform `System.arraycopy` in microbenchmarks and I opted to go with `arraycopy` throughout while investigating. Testing on x86 (SandyBridge, AVX2) I observe no difference at all between the setups. On aarch the only

Integrated: 8302163: Speed up various String comparison methods with ArraysSupport.mismatch

2023-02-15 Thread Claes Redestad
On Mon, 13 Feb 2023 09:59:24 GMT, Claes Redestad wrote: > We can improve various String methods such as `startsWith`, `endsWith` and > `regionMatches` by leveraging the intrinsified mismatch methods in > `ArraysSupport`. This pull request has now been integrated. Changeset: 861e30

Re: RFR: 8302163: Speed up various String comparison methods with ArraysSupport.mismatch [v2]

2023-02-15 Thread Claes Redestad
On Mon, 13 Feb 2023 16:10:14 GMT, Claes Redestad wrote: >> We can improve various String methods such as `startsWith`, `endsWith` and >> `regionMatches` by leveraging the intrinsified mismatch methods in >> `ArraysSupport`. > > Claes Redestad has updated the pull reques

Re: RFR: JDK-8300808: Accelerate Base64 on x86 for AVX2 [v17]

2023-02-15 Thread Claes Redestad
On Tue, 14 Feb 2023 18:22:32 GMT, Scott Gibbons wrote: >> Added code for Base64 acceleration (encode and decode) which will accelerate >> ~4x for AVX2 platforms. >> >> Encode performance: >> **Old:** >> >> Benchmark (maxNumBytes) Mode Cnt Score Error >> Units

Re: RFR: JDK-8300808: Accelerate Base64 on x86 for AVX2 [v17]

2023-02-14 Thread Claes Redestad
On Tue, 14 Feb 2023 18:22:32 GMT, Scott Gibbons wrote: >> Added code for Base64 acceleration (encode and decode) which will accelerate >> ~4x for AVX2 platforms. >> >> Encode performance: >> **Old:** >> >> Benchmark (maxNumBytes) Mode Cnt Score Error >> Units

Re: RFR: JDK-8300808: Accelerate Base64 on x86 for AVX2 [v15]

2023-02-14 Thread Claes Redestad
On Tue, 14 Feb 2023 15:03:50 GMT, Scott Gibbons wrote: >> src/hotspot/cpu/x86/stubGenerator_x86_64.cpp line 2699: >> >>> 2697: __ addptr(dest, 0x18); >>> 2698: __ subl(length, 0x20); >>> 2699: __ jcc(Assembler::lessEqual, L_tailProc); >> >> This could be Assembler::less instead of

Re: RFR: JDK-8300808: Accelerate Base64 on x86 for AVX2 [v15]

2023-02-14 Thread Claes Redestad
On Fri, 10 Feb 2023 23:18:47 GMT, Claes Redestad wrote: >> Scott Gibbons has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Add URL to microbenchmark > > Marked as reviewed by redestad (Reviewer). &g

Re: RFR: 8302163: Speed up various String comparison methods with ArraysSupport.mismatch [v2]

2023-02-14 Thread Claes Redestad
On Mon, 13 Feb 2023 16:43:12 GMT, Eirik Bjorsnos wrote: > Case-insensitive regionMatches could be improved by using > ArraysSupport.mismatch to skip over long common substrings: I considered this but saw regressions similar to what you're getting for size = 6 and backed off. I think this

Re: RFR: 8301958: Reduce Arrays.copyOf/-Range overheads [v10]

2023-02-13 Thread Claes Redestad
On Mon, 13 Feb 2023 09:59:52 GMT, Claes Redestad wrote: >> This patch adds special-cases to `Arrays.copyOf` and `Arrays.copyOfRange` to >> copy arrays more efficiently when exactly the whole input array is to be >> copied. This helps eliminate range checks and has bee

Integrated: 8301958: Reduce Arrays.copyOf/-Range overheads

2023-02-13 Thread Claes Redestad
On Tue, 7 Feb 2023 13:30:35 GMT, Claes Redestad wrote: > This patch adds special-cases to `Arrays.copyOf` and `Arrays.copyOfRange` to > copy arrays more efficiently when exactly the whole input array is to be > copied. This helps eliminate range checks and has been verified to help

Re: RFR: 8302163: Speed up various String comparison methods with ArraysSupport.mismatch

2023-02-13 Thread Claes Redestad
On Mon, 13 Feb 2023 09:59:24 GMT, Claes Redestad wrote: > We can improve various String methods such as `startsWith`, `endsWith` and > `regionMatches` by leveraging the intrinsified mismatch methods in > `ArraysSupport`. Microbenchmarking shows decent improvements on small data, s

RFR: 8302163: Speed up various String comparison methods with ArraysSupport.mismatch

2023-02-13 Thread Claes Redestad
We can improve various String methods such as `startsWith`, `endsWith` and `regionMatches` by leveraging the intrinsified mismatch methods in `ArraysSupport`. - Commit messages: - Remove overlapping micros, extend testing to endsWith, regionCI and some minor improvements to

Re: RFR: 8301958: Reduce Arrays.copyOf/-Range overheads [v10]

2023-02-13 Thread Claes Redestad
ray 7 avgt 15 > 14.666 ± 0.336 ns/op > StringConstructor.newStringFromArrayWithCharset 7 avgt 15 > 14.582 ± 0.288 ns/op > StringConstructor.newStringFromArrayWithCharsetName 7 avgt 15 > 20.339 ± 0.328 ns/op Claes Redestad has upd

Re: RFR: JDK-8300808: Accelerate Base64 on x86 for AVX2 [v15]

2023-02-10 Thread Claes Redestad
On Thu, 9 Feb 2023 18:08:15 GMT, Scott Gibbons wrote: >> Added code for Base64 acceleration (encode and decode) which will accelerate >> ~4x for AVX2 platforms. >> >> Encode performance: >> **Old:** >> >> Benchmark (maxNumBytes) Mode Cnt Score Error >> Units

Re: RFR: 8301873: Avoid string decoding in ZipFile.Source.getEntryPos [v7]

2023-02-09 Thread Claes Redestad
On Thu, 9 Feb 2023 11:46:42 GMT, Eirik Bjorsnos wrote: > > In addition to - or instead of - an `equals` shortcut then if coders are > > the same we could use `ArraysSupport.mismatch` which should get similar > > speed and help more generally. > > ..and if String had (an optimized) mismatch

Re: RFR: 8301873: Avoid string decoding in ZipFile.Source.getEntryPos [v7]

2023-02-09 Thread Claes Redestad
On Wed, 8 Feb 2023 16:36:16 GMT, Eirik Bjorsnos wrote: >> After finding a hash match, getEntryPos needs to compare the lookup name up >> to the encoded entry name in the CEN. This comparison is done by decoding >> the entry name into a String. The names can then be compared using the >>

Re: RFR: 8301873: Avoid string decoding in ZipFile.Source.getEntryPos [v7]

2023-02-09 Thread Claes Redestad
On Wed, 8 Feb 2023 16:36:16 GMT, Eirik Bjorsnos wrote: >> After finding a hash match, getEntryPos needs to compare the lookup name up >> to the encoded entry name in the CEN. This comparison is done by decoding >> the entry name into a String. The names can then be compared using the >>

Re: RFR: 8301873: Avoid string decoding in ZipFile.Source.getEntryPos [v7]

2023-02-08 Thread Claes Redestad
On Wed, 8 Feb 2023 16:36:16 GMT, Eirik Bjorsnos wrote: >> After finding a hash match, getEntryPos needs to compare the lookup name up >> to the encoded entry name in the CEN. This comparison is done by decoding >> the entry name into a String. The names can then be compared using the >>

Re: RFR: 8301873: Avoid string decoding in ZipFile.Source.getEntryPos [v6]

2023-02-08 Thread Claes Redestad
On Wed, 8 Feb 2023 15:31:15 GMT, Eirik Bjorsnos wrote: >> After finding a hash match, getEntryPos needs to compare the lookup name up >> to the encoded entry name in the CEN. This comparison is done by decoding >> the entry name into a String. The names can then be compared using the >>

Re: RFR: 8301873: Avoid string decoding in ZipFile.Source.getEntryPos [v4]

2023-02-08 Thread Claes Redestad
On Wed, 8 Feb 2023 11:57:16 GMT, Claes Redestad wrote: > > > Seems there's a possible real test failure lurking here, might be > > > intermittent since it only showed on one platform: > > > > > > Did you get this from GHA somehow? Do you happen to know the

Re: RFR: 8301873: Avoid string decoding in ZipFile.Source.getEntryPos [v4]

2023-02-08 Thread Claes Redestad
On Wed, 8 Feb 2023 11:32:02 GMT, Eirik Bjorsnos wrote: > > Seems there's a possible real test failure lurking here, might be > > intermittent since it only showed on one platform: > > Did you get this from GHA somehow? Do you happen to know the platform, > timezone and encoding used? Yes,

Re: RFR: 8301958: Reduce Arrays.copyOf/-Range overheads [v7]

2023-02-08 Thread Claes Redestad
On Wed, 8 Feb 2023 08:16:05 GMT, Francesco Nigro wrote: >> Claes Redestad has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Minimize, force inline, generalize > > test/micro/org/openjdk/bench/java/lang/

Re: RFR: 8301958: Reduce Arrays.copyOf/-Range overheads [v7]

2023-02-08 Thread Claes Redestad
On Wed, 8 Feb 2023 03:38:24 GMT, David Schlosnagle wrote: >> Claes Redestad has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Minimize, force inline, generalize > > src/java.base/share/classes/java/util/Arr

Re: RFR: 8301958: Reduce Arrays.copyOf/-Range overheads [v9]

2023-02-08 Thread Claes Redestad
ray 7 avgt 15 > 14.666 ± 0.336 ns/op > StringConstructor.newStringFromArrayWithCharset 7 avgt 15 > 14.582 ± 0.288 ns/op > StringConstructor.newStringFromArrayWithCharsetName 7 avgt 15 > 20.339 ± 0.328 ns/op Claes Redestad has updated the

Re: RFR: 8301958: Reduce Arrays.copyOf/-Range overheads [v7]

2023-02-08 Thread Claes Redestad
On Wed, 8 Feb 2023 01:10:59 GMT, David Schlosnagle wrote: >> Claes Redestad has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Minimize, force inline, generalize > > src/java.base/share/classes/java/util/Arr

Re: RFR: 8301958: Reduce Arrays.copyOf/-Range overheads [v8]

2023-02-08 Thread Claes Redestad
ray 7 avgt 15 > 14.666 ± 0.336 ns/op > StringConstructor.newStringFromArrayWithCharset 7 avgt 15 > 14.582 ± 0.288 ns/op > StringConstructor.newStringFromArrayWithCharsetName 7 avgt 15 > 20.339 ± 0.328 ns/op Claes Redestad has updated the

Re: RFR: 8301958: Reduce Arrays.copyOf/-Range overheads [v7]

2023-02-07 Thread Claes Redestad
ray 7 avgt 15 > 14.666 ± 0.336 ns/op > StringConstructor.newStringFromArrayWithCharset 7 avgt 15 > 14.582 ± 0.288 ns/op > StringConstructor.newStringFromArrayWithCharsetName 7 avgt 15 > 20.339 ± 0.328 ns/op Claes Redestad has updated the

Re: RFR: 8301873: Avoid string decoding in ZipFile.Source.getEntryPos [v4]

2023-02-07 Thread Claes Redestad
On Tue, 7 Feb 2023 13:23:26 GMT, Eirik Bjorsnos wrote: >> After finding a hash match, getEntryPos needs to compare the lookup name up >> to the encoded entry name in the CEN. This comparison is done by decoding >> the entry name into a String. The names can then be compared using the >>

Re: RFR: 8301958: Avoid Arrays.copyOfRange overhead in java.lang.String [v5]

2023-02-07 Thread Claes Redestad
On Tue, 7 Feb 2023 19:10:08 GMT, Francesco Nigro wrote: >> Claes Redestad has updated the pull request incrementally with one >> additional commit since the last revision: >> >> copyrights > > Thanks @cl4es to look into this! @franz1981 idea seems to app

Re: RFR: 8301958: Avoid Arrays.copyOfRange overhead in java.lang.String [v6]

2023-02-07 Thread Claes Redestad
s not > in agreement (theoretically possible if you clear/remove and call > `trimToSize()` concurrently). Adding an explicit check here seem to be the > right thing to do regardless of this RFE. Claes Redestad has updated the pull request incrementally with two additional commits si

Re: RFR: 8301958: Avoid Arrays.copyOfRange overhead in java.lang.String [v5]

2023-02-07 Thread Claes Redestad
On Tue, 7 Feb 2023 19:08:59 GMT, Francesco Nigro wrote: >> Claes Redestad has updated the pull request incrementally with one >> additional commit since the last revision: >> >> copyrights > > src/java.base/share/classes/java/lang/String.java line 698: &g

Re: RFR: 8301958: Avoid Arrays.copyOfRange overhead in java.lang.String [v5]

2023-02-07 Thread Claes Redestad
On Tue, 7 Feb 2023 15:25:05 GMT, Claes Redestad wrote: >> This adds a local, specialized `copyBytes` method to `String` that avoids >> certain redundant range checks and clamping that JIT has issues removing >> fully. >> >> This has a small but statistically

Re: RFR: 8301958: Avoid Arrays.copyOfRange overhead in java.lang.String [v5]

2023-02-07 Thread Claes Redestad
On Tue, 7 Feb 2023 19:24:11 GMT, Stuart Marks wrote: > > It might be that the redundant checks in Arrays.copyOfRange would be > > eliminated properly with more inlining, and that the issue here is that the > > affected String constructor is particularly gnarly. This gnarliness is due > > 1)

Re: RFR: 8301958: Avoid Arrays.copyOfRange overhead in java.lang.String [v5]

2023-02-07 Thread Claes Redestad
On Tue, 7 Feb 2023 18:35:32 GMT, John R Rose wrote: > Our source code is a reference implementation, and people will look at this > change as evidence that `Arrays::copyOfRange` should be hand-inlined by savvy > coders. Surely we could also fix this small performance pothole by improving >

Re: RFR: 8301958: Avoid Arrays.copyOfRange overhead in java.lang.String [v5]

2023-02-07 Thread Claes Redestad
s not > in agreement (theoretically possible if you clear/remove and call > `trimToSize()` concurrently). Adding an explicit check here seem to be the > right thing to do regardless of this RFE. Claes Redestad has updated the pull request incrementally with one additional commit sin

Re: RFR: 8301958: Avoid Arrays.copyOfRange overhead in java.lang.String [v3]

2023-02-07 Thread Claes Redestad
On Tue, 7 Feb 2023 14:57:52 GMT, Alan Bateman wrote: >> Claes Redestad has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Update StringLatin1.trim for consistency > > src/java.base/share/classes/java/lang/Str

Re: RFR: 8301958: Avoid Arrays.copyOfRange overhead in java.lang.String [v4]

2023-02-07 Thread Claes Redestad
s not > in agreement (theoretically possible if you clear/remove and call > `trimToSize()` concurrently). Adding an explicit check here seem to be the > right thing to do regardless of this RFE. Claes Redestad has updated the pull request incrementally with one additional commit

Re: RFR: 8301958: Avoid Arrays.copyOfRange overhead in java.lang.String [v2]

2023-02-07 Thread Claes Redestad
s not > in agreement (theoretically possible if you clear/remove and call > `trimToSize()` concurrently). Adding an explicit check here seem to be the > right thing to do regardless of this RFE. Claes Redestad has updated the pull request incrementally with one additional commit since

Re: RFR: 8301958: Avoid Arrays.copyOfRange overhead in java.lang.String [v3]

2023-02-07 Thread Claes Redestad
s not > in agreement (theoretically possible if you clear/remove and call > `trimToSize()` concurrently). Adding an explicit check here seem to be the > right thing to do regardless of this RFE. Claes Redestad has updated the pull request incrementally with one additional c

RFR: 8301958: Avoid Arrays.copyOfRange overhead in java.lang.String

2023-02-07 Thread Claes Redestad
This adds a local, specialized `copyBytes` method to `String` that avoids certain redundant range checks and clamping that JIT has issues removing fully. This has a small but statistically significant effect on `String` microbenchmarks, eg.: Baseline Benchmark

Re: RFR: 8301873: Avoid string decoding in ZipFile.Source.getEntryPos [v3]

2023-02-07 Thread Claes Redestad
On Mon, 6 Feb 2023 16:14:14 GMT, Eirik Bjorsnos wrote: >> After finding a hash match, getEntryPos needs to compare the lookup name up >> to the encoded entry name in the CEN. This comparison is done by decoding >> the entry name into a String. The names can then be compared using the >>

Re: RFR: 8301873: Avoid string decoding in ZipFile.Source.getEntryPos [v2]

2023-02-06 Thread Claes Redestad
On Mon, 6 Feb 2023 15:21:10 GMT, Eirik Bjorsnos wrote: >> After finding a hash match, getEntryPos needs to compare the lookup name up >> to the encoded entry name in the CEN. This comparison is done by decoding >> the entry name into a String. The names can then be compared using the >>

Re: RFR: 8301873: Avoid string decoding in ZipFile.Source.getEntryPos [v2]

2023-02-06 Thread Claes Redestad
On Mon, 6 Feb 2023 15:21:10 GMT, Eirik Bjorsnos wrote: >> After finding a hash match, getEntryPos needs to compare the lookup name up >> to the encoded entry name in the CEN. This comparison is done by decoding >> the entry name into a String. The names can then be compared using the >>

Re: RFR: 8301873: Avoid string decoding in ZipFile.Source.getEntryPos [v2]

2023-02-06 Thread Claes Redestad
On Mon, 6 Feb 2023 15:14:37 GMT, Eirik Bjorsnos wrote: >> Eirik Bjorsnos has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Spelling fix in test data for non-ascii latin1 string > > test/jdk/java/util/zip/ZipFile/TestZipFileEncodings.java

Re: RFR: 8301873: Avoid string decoding in ZipFile.Source.getEntryPos

2023-02-06 Thread Claes Redestad
On Mon, 6 Feb 2023 12:01:19 GMT, Eirik Bjorsnos wrote: >> Nice, I have updated the PR such that the new shared secret is replaced with >> using getBytesNoRepl instead. If there is a performance difference, it seems >> to hide in the noise. >> >> I had expected such a regression to be caught

Re: RFR: 8301873: Avoid string decoding in ZipFile.Source.getEntryPos

2023-02-06 Thread Claes Redestad
On Mon, 30 Jan 2023 10:32:38 GMT, Eirik Bjorsnos wrote: > After finding a hash match, getEntryPos needs to compare the lookup name up > to the encoded entry name in the CEN. This comparison is done by decoding the > entry name into a String. The names can then be compared using the String >

Re: RFR: 8301873: Avoid string decoding in ZipFile.Source.getEntryPos

2023-02-06 Thread Claes Redestad
On Mon, 6 Feb 2023 14:27:36 GMT, Claes Redestad wrote: >> Interesting. Would be nice to solve this in the JIT! >> >> This disabled code got deleted in my last commit, but it seems like you have >> a good analysis so we can let it go now. > > Right. I might have

Re: RFR: 8301873: Avoid string decoding in ZipFile.Source.getEntryPos

2023-02-06 Thread Claes Redestad
On Mon, 6 Feb 2023 11:56:22 GMT, Eirik Bjorsnos wrote: >> src/java.base/share/classes/java/lang/System.java line 2671: >> >>> 2669: if (false) { >>> 2670: // Arrays.mismatch without the range checks (~5% >>> faster micro getEntryHit) >>> 2671:

Re: RFR: JDK-8300808: Accelerate Base64 on x86 for AVX2 [v7]

2023-02-05 Thread Claes Redestad
On Thu, 2 Feb 2023 15:33:29 GMT, Scott Gibbons wrote: >> Names are important, but always hard to get right. At the very least they >> need to be correct. Maybe call it something like >> `..parameterized_decode_tables..` and the other `..shared_decode_tables..`? > > I prefer leaving them the

Re: RFR: JDK-8300808: Accelerate Base64 on x86 for AVX2 [v7]

2023-02-01 Thread Claes Redestad
On Wed, 1 Feb 2023 20:59:24 GMT, Scott Gibbons wrote: >> src/hotspot/cpu/x86/stubGenerator_x86_64.cpp line 2202: >> >>> 2200: } >>> 2201: >>> 2202: address StubGenerator::base64_AVX2_decode_URL_tables_addr() { >> >> Shouldn't this be `decode_lut_tables`? As it's used for URL and non-URL >>

Re: RFR: JDK-8300808: Accelerate Base64 on x86 for AVX2 [v7]

2023-02-01 Thread Claes Redestad
On Wed, 1 Feb 2023 18:28:25 GMT, Scott Gibbons wrote: >> Added code for Base64 acceleration (encode and decode) which will accelerate >> ~4x for AVX2 platforms. >> >> Encode performance: >> **Old:** >> >> Benchmark (maxNumBytes) Mode Cnt Score Error >> Units

Re: RFR: JDK-8300808: Accelerate Base64 on x86 for AVX2 [v6]

2023-01-27 Thread Claes Redestad
On Fri, 27 Jan 2023 21:36:29 GMT, Claes Redestad wrote: >> Scott Gibbons 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

<    1   2   3   4   5   6   7   8   >