Re: RFR: 8327791: Optimization for new BigDecimal(String) [v18]

2024-04-27 Thread Chen Liang
On Sat, 27 Apr 2024 10:48:38 GMT, Shaojin Wen wrote: >> Shaojin Wen 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 sin

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v18]

2024-04-27 Thread Shaojin Wen
On Fri, 26 Apr 2024 05:48:03 GMT, Shaojin Wen wrote: >> The current BigDecimal(String) constructor calls String#toCharArray, which >> has a memory allocation. >> >> >> public BigDecimal(String val) { >> this(val.toCharArray(), 0, val.length()); // allocate char[] >> } >> >> >> When the l

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v18]

2024-04-25 Thread Shaojin Wen
> The current BigDecimal(String) constructor calls String#toCharArray, which > has a memory allocation. > > > public BigDecimal(String val) { > this(val.toCharArray(), 0, val.length()); // allocate char[] > } > > > When the length is greater than 18, create a char[] > > > boolean isCompa

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v10]

2024-04-25 Thread Shaojin Wen
On Fri, 26 Apr 2024 02:04:38 GMT, Joe Darcy wrote: >>> @cl4es @jddarcy All feedback has been fixed, can it be integrated? >> >> Hello @wenshao , >> >> This change will need additional review from myself or others who maintain >> BigDecimal before it can be integrated. > >> @jddarcy Sorry for t

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v10]

2024-04-25 Thread Joe Darcy
On Tue, 19 Mar 2024 19:32:10 GMT, Joe Darcy wrote: >> I think splitting `CharArraySequence` into two versions is somewhat dubious >> as more observable types at call sites may mean the performance gain in >> targeted micros is lost. How much of an improvement did you observe from >> this? Agai

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v10]

2024-04-25 Thread Shaojin Wen
On Tue, 19 Mar 2024 19:32:10 GMT, Joe Darcy wrote: >> I think splitting `CharArraySequence` into two versions is somewhat dubious >> as more observable types at call sites may mean the performance gain in >> targeted micros is lost. How much of an improvement did you observe from >> this? Agai

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v17]

2024-04-23 Thread Shaojin Wen
> The current BigDecimal(String) constructor calls String#toCharArray, which > has a memory allocation. > > > public BigDecimal(String val) { > this(val.toCharArray(), 0, val.length()); // allocate char[] > } > > > When the length is greater than 18, create a char[] > > > boolean isCompa

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v16]

2024-03-27 Thread Shaojin Wen
On Wed, 20 Mar 2024 22:56:38 GMT, Shaojin Wen wrote: >> The current BigDecimal(String) constructor calls String#toCharArray, which >> has a memory allocation. >> >> >> public BigDecimal(String val) { >> this(val.toCharArray(), 0, val.length()); // allocate char[] >> } >> >> >> When the l

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v16]

2024-03-26 Thread Claes Redestad
On Wed, 20 Mar 2024 22:56:38 GMT, Shaojin Wen wrote: >> The current BigDecimal(String) constructor calls String#toCharArray, which >> has a memory allocation. >> >> >> public BigDecimal(String val) { >> this(val.toCharArray(), 0, val.length()); // allocate char[] >> } >> >> >> When the l

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v16]

2024-03-20 Thread Chen Liang
On Thu, 21 Mar 2024 00:40:45 GMT, Shaojin Wen wrote: > Should we declare the BigDecimal(CharSequence,MathContext) method as public? > Scenarios like > [MysqlBinaryValueDecoder#decodeDecimal](https://github.com/mysql/mysql-connector-j/blob/release/8.x/src/main/protocol-impl/java/com/mysql/cj/pro

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v16]

2024-03-20 Thread Shaojin Wen
On Wed, 20 Mar 2024 22:56:38 GMT, Shaojin Wen wrote: >> The current BigDecimal(String) constructor calls String#toCharArray, which >> has a memory allocation. >> >> >> public BigDecimal(String val) { >> this(val.toCharArray(), 0, val.length()); // allocate char[] >> } >> >> >> When the l

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v16]

2024-03-20 Thread Shaojin Wen
> The current BigDecimal(String) constructor calls String#toCharArray, which > has a memory allocation. > > > public BigDecimal(String val) { > this(val.toCharArray(), 0, val.length()); // allocate char[] > } > > > When the length is greater than 18, create a char[] > > > boolean isCompa

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v15]

2024-03-20 Thread Shaojin Wen
> The current BigDecimal(String) constructor calls String#toCharArray, which > has a memory allocation. > > > public BigDecimal(String val) { > this(val.toCharArray(), 0, val.length()); // allocate char[] > } > > > When the length is greater than 18, create a char[] > > > boolean isCompa

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v14]

2024-03-20 Thread Claes Redestad
On Thu, 14 Mar 2024 00:00:53 GMT, Shaojin Wen wrote: >> The current BigDecimal(String) constructor calls String#toCharArray, which >> has a memory allocation. >> >> >> public BigDecimal(String val) { >> this(val.toCharArray(), 0, val.length()); // allocate char[] >> } >> >> >> When the l

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v14]

2024-03-20 Thread Claes Redestad
On Thu, 14 Mar 2024 00:00:53 GMT, Shaojin Wen wrote: >> The current BigDecimal(String) constructor calls String#toCharArray, which >> has a memory allocation. >> >> >> public BigDecimal(String val) { >> this(val.toCharArray(), 0, val.length()); // allocate char[] >> } >> >> >> When the l

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v10]

2024-03-19 Thread Raffaello Giulietti
On Tue, 19 Mar 2024 12:12:30 GMT, Shaojin Wen wrote: >> I think splitting `CharArraySequence` into two versions is somewhat dubious >> as more observable types at call sites may mean the performance gain in >> targeted micros is lost. How much of an improvement did you observe from >> this? Ag

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v10]

2024-03-19 Thread Joe Darcy
On Tue, 12 Mar 2024 14:03:01 GMT, Claes Redestad wrote: >> Shaojin Wen has updated the pull request incrementally with one additional >> commit since the last revision: >> >> restore comment > > I think splitting `CharArraySequence` into two versions is somewhat dubious > as more observable

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v10]

2024-03-19 Thread Shaojin Wen
On Tue, 12 Mar 2024 14:03:01 GMT, Claes Redestad wrote: >> Shaojin Wen has updated the pull request incrementally with one additional >> commit since the last revision: >> >> restore comment > > I think splitting `CharArraySequence` into two versions is somewhat dubious > as more observable

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v12]

2024-03-14 Thread Shaojin Wen
On Wed, 13 Mar 2024 15:43:25 GMT, Joe Darcy wrote: >> Relying on the upper bounds check of `charAt` doesn't work well with the >> `CharArraySequence` whose `charAt` deliberately does not throw an IIOBE if >> the array is longer than the provided length, ie, it'll look at chars beyond >> the pr

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v13]

2024-03-13 Thread Shaojin Wen
On Wed, 13 Mar 2024 16:02:29 GMT, Chen Liang wrote: >> Shaojin Wen has updated the pull request incrementally with one additional >> commit since the last revision: >> >> bug fix for CharArraySequence > > src/java.base/share/classes/java/math/BigDecimal.java line 561: > >> 559: i

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v14]

2024-03-13 Thread Shaojin Wen
> The current BigDecimal(String) constructor calls String#toCharArray, which > has a memory allocation. > > > public BigDecimal(String val) { > this(val.toCharArray(), 0, val.length()); // allocate char[] > } > > > When the length is greater than 18, create a char[] > > > boolean isCompa

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v13]

2024-03-13 Thread Chen Liang
On Wed, 13 Mar 2024 15:46:30 GMT, Shaojin Wen wrote: >> The current BigDecimal(String) constructor calls String#toCharArray, which >> has a memory allocation. >> >> >> public BigDecimal(String val) { >> this(val.toCharArray(), 0, val.length()); // allocate char[] >> } >> >> >> When the l

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v12]

2024-03-13 Thread Joe Darcy
On Wed, 13 Mar 2024 13:51:27 GMT, Claes Redestad wrote: > Relying on the upper bounds check of `charAt` doesn't work well with the > `CharArraySequence` whose `charAt` deliberately does not throw an IIOBE if > the array is longer than the provided length, ie, it'll look at chars beyond > the p

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v13]

2024-03-13 Thread Shaojin Wen
> The current BigDecimal(String) constructor calls String#toCharArray, which > has a memory allocation. > > > public BigDecimal(String val) { > this(val.toCharArray(), 0, val.length()); // allocate char[] > } > > > When the length is greater than 18, create a char[] > > > boolean isCompa

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v12]

2024-03-13 Thread Claes Redestad
On Wed, 13 Mar 2024 13:12:54 GMT, Shaojin Wen wrote: >> If the input is "+" or "-" an exception will be thrown on line 583 >> >> boolean isneg = c == '-'; // leading minus means negative >> if (isneg || c == '+') { >> c = val.charAt(++offset); >>

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v12]

2024-03-13 Thread Shaojin Wen
On Wed, 13 Mar 2024 12:12:20 GMT, Claes Redestad wrote: >> Shaojin Wen has updated the pull request incrementally with one additional >> commit since the last revision: >> >> fix benchmark > > src/java.base/share/classes/java/math/BigDecimal.java line 596: > >> 594: // First

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v12]

2024-03-13 Thread Shaojin Wen
On Wed, 13 Mar 2024 13:11:48 GMT, Shaojin Wen wrote: >> src/java.base/share/classes/java/math/BigDecimal.java line 596: >> >>> 594: // First compact case, we need not to preserve the >>> character >>> 595: // and we can just compute the value in place. >>> 596:

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v12]

2024-03-13 Thread Claes Redestad
On Wed, 13 Mar 2024 09:52:45 GMT, Shaojin Wen wrote: >> The current BigDecimal(String) constructor calls String#toCharArray, which >> has a memory allocation. >> >> >> public BigDecimal(String val) { >> this(val.toCharArray(), 0, val.length()); // allocate char[] >> } >> >> >> When the l

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v12]

2024-03-13 Thread Shaojin Wen
> The current BigDecimal(String) constructor calls String#toCharArray, which > has a memory allocation. > > > public BigDecimal(String val) { > this(val.toCharArray(), 0, val.length()); // allocate char[] > } > > > When the length is greater than 18, create a char[] > > > boolean isCompa

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v11]

2024-03-12 Thread Claes Redestad
On Tue, 12 Mar 2024 19:09:27 GMT, Shaojin Wen wrote: >> The current BigDecimal(String) constructor calls String#toCharArray, which >> has a memory allocation. >> >> >> public BigDecimal(String val) { >> this(val.toCharArray(), 0, val.length()); // allocate char[] >> } >> >> >> When the l

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v11]

2024-03-12 Thread Shaojin Wen
> The current BigDecimal(String) constructor calls String#toCharArray, which > has a memory allocation. > > > public BigDecimal(String val) { > this(val.toCharArray(), 0, val.length()); // allocate char[] > } > > > When the length is greater than 18, create a char[] > > > boolean isCompa

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v10]

2024-03-12 Thread Shaojin Wen
On Tue, 12 Mar 2024 13:07:26 GMT, Shaojin Wen wrote: >> The current BigDecimal(String) constructor calls String#toCharArray, which >> has a memory allocation. >> >> >> public BigDecimal(String val) { >> this(val.toCharArray(), 0, val.length()); // allocate char[] >> } >> >> >> When the l

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v10]

2024-03-12 Thread Claes Redestad
On Tue, 12 Mar 2024 13:07:26 GMT, Shaojin Wen wrote: >> The current BigDecimal(String) constructor calls String#toCharArray, which >> has a memory allocation. >> >> >> public BigDecimal(String val) { >> this(val.toCharArray(), 0, val.length()); // allocate char[] >> } >> >> >> When the l

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v10]

2024-03-12 Thread Shaojin Wen
> The current BigDecimal(String) constructor calls String#toCharArray, which > has a memory allocation. > > > public BigDecimal(String val) { > this(val.toCharArray(), 0, val.length()); // allocate char[] > } > > > When the length is greater than 18, create a char[] > > > boolean isCompa

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v6]

2024-03-12 Thread Shaojin Wen
On Tue, 12 Mar 2024 09:41:46 GMT, Claes Redestad wrote: >> Shaojin Wen has updated the pull request incrementally with one additional >> commit since the last revision: >> >> easier to compare > > Sorry, when I got pinged in here the earlier comments didn't render and I > missed the conversa

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v9]

2024-03-12 Thread Shaojin Wen
> The current BigDecimal(String) constructor calls String#toCharArray, which > has a memory allocation. > > > public BigDecimal(String val) { > this(val.toCharArray(), 0, val.length()); // allocate char[] > } > > > When the length is greater than 18, create a char[] > > > boolean isCompa

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v8]

2024-03-12 Thread Claes Redestad
On Tue, 12 Mar 2024 10:34:33 GMT, Shaojin Wen wrote: >> The current BigDecimal(String) constructor calls String#toCharArray, which >> has a memory allocation. >> >> >> public BigDecimal(String val) { >> this(val.toCharArray(), 0, val.length()); // allocate char[] >> } >> >> >> When the l

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v8]

2024-03-12 Thread Claes Redestad
On Tue, 12 Mar 2024 10:34:33 GMT, Shaojin Wen wrote: >> The current BigDecimal(String) constructor calls String#toCharArray, which >> has a memory allocation. >> >> >> public BigDecimal(String val) { >> this(val.toCharArray(), 0, val.length()); // allocate char[] >> } >> >> >> When the l

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v8]

2024-03-12 Thread Claes Redestad
On Tue, 12 Mar 2024 10:34:33 GMT, Shaojin Wen wrote: >> The current BigDecimal(String) constructor calls String#toCharArray, which >> has a memory allocation. >> >> >> public BigDecimal(String val) { >> this(val.toCharArray(), 0, val.length()); // allocate char[] >> } >> >> >> When the l

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v8]

2024-03-12 Thread Shaojin Wen
> The current BigDecimal(String) constructor calls String#toCharArray, which > has a memory allocation. > > > public BigDecimal(String val) { > this(val.toCharArray(), 0, val.length()); // allocate char[] > } > > > When the length is greater than 18, create a char[] > > > boolean isCompa

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v7]

2024-03-12 Thread Shaojin Wen
> The current BigDecimal(String) constructor calls String#toCharArray, which > has a memory allocation. > > > public BigDecimal(String val) { > this(val.toCharArray(), 0, val.length()); // allocate char[] > } > > > When the length is greater than 18, create a char[] > > > boolean isCompa

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v6]

2024-03-12 Thread Claes Redestad
On Tue, 12 Mar 2024 06:18:27 GMT, Shaojin Wen wrote: >> The current BigDecimal(String) constructor calls String#toCharArray, which >> has a memory allocation. >> >> >> public BigDecimal(String val) { >> this(val.toCharArray(), 0, val.length()); // allocate char[] >> } >> >> >> When the l

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v6]

2024-03-11 Thread Shaojin Wen
> The current BigDecimal(String) constructor calls String#toCharArray, which > has a memory allocation. > > > public BigDecimal(String val) { > this(val.toCharArray(), 0, val.length()); // allocate char[] > } > > > When the length is greater than 18, create a char[] > > > boolean isCompa

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v5]

2024-03-11 Thread Chen Liang
On Tue, 12 Mar 2024 03:28:24 GMT, Shaojin Wen wrote: >> The current BigDecimal(String) constructor calls String#toCharArray, which >> has a memory allocation. >> >> >> public BigDecimal(String val) { >> this(val.toCharArray(), 0, val.length()); // allocate char[] >> } >> >> >> When the l

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v5]

2024-03-11 Thread Shaojin Wen
> The current BigDecimal(String) constructor calls String#toCharArray, which > has a memory allocation. > > > public BigDecimal(String val) { > this(val.toCharArray(), 0, val.length()); // allocate char[] > } > > > When the length is greater than 18, create a char[] > > > boolean isCompa

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v4]

2024-03-11 Thread Chen Liang
On Mon, 11 Mar 2024 20:41:25 GMT, Shaojin Wen wrote: >> The current BigDecimal(String) constructor calls String#toCharArray, which >> has a memory allocation. >> >> >> public BigDecimal(String val) { >> this(val.toCharArray(), 0, val.length()); // allocate char[] >> } >> >> >> When the l

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v4]

2024-03-11 Thread Joe Darcy
On Mon, 11 Mar 2024 20:41:25 GMT, Shaojin Wen wrote: >> The current BigDecimal(String) constructor calls String#toCharArray, which >> has a memory allocation. >> >> >> public BigDecimal(String val) { >> this(val.toCharArray(), 0, val.length()); // allocate char[] >> } >> >> >> When the l

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v4]

2024-03-11 Thread Shaojin Wen
On Mon, 11 Mar 2024 20:41:25 GMT, Shaojin Wen wrote: >> The current BigDecimal(String) constructor calls String#toCharArray, which >> has a memory allocation. >> >> >> public BigDecimal(String val) { >> this(val.toCharArray(), 0, val.length()); // allocate char[] >> } >> >> >> When the l

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v4]

2024-03-11 Thread Shaojin Wen
> The current BigDecimal(String) constructor calls String#toCharArray, which > has a memory allocation. > > > public BigDecimal(String val) { > this(val.toCharArray(), 0, val.length()); // allocate char[] > } > > > When the length is greater than 18, create a char[] > > > boolean isCompa

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v3]

2024-03-11 Thread Shaojin Wen
On Mon, 11 Mar 2024 18:03:06 GMT, Shaojin Wen wrote: >> The current BigDecimal(String) constructor calls String#toCharArray, which >> has a memory allocation. >> >> >> public BigDecimal(String val) { >> this(val.toCharArray(), 0, val.length()); // allocate char[] >> } >> >> >> When the l

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v3]

2024-03-11 Thread Shaojin Wen
> The current BigDecimal(String) constructor calls String#toCharArray, which > has a memory allocation. > > > public BigDecimal(String val) { > this(val.toCharArray(), 0, val.length()); // allocate char[] > } > > > When the length is greater than 18, create a char[] > > > boolean isCompa

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v2]

2024-03-11 Thread Chen Liang
On Mon, 11 Mar 2024 13:54:06 GMT, Shaojin Wen wrote: >> The current BigDecimal(String) constructor calls String#toCharArray, which >> has a memory allocation. >> >> >> public BigDecimal(String val) { >> this(val.toCharArray(), 0, val.length()); // allocate char[] >> } >> >> >> When the l

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v2]

2024-03-11 Thread Raffaello Giulietti
On Mon, 11 Mar 2024 14:42:03 GMT, Claes Redestad wrote: >> Looks great to me. Sorry for the pings, but we may need @rgiulietti to >> verify the math correctness and @cl4es to comment on whether having these 2 >> separate code paths or trying to extract a common part is the better >> approach.

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v2]

2024-03-11 Thread Claes Redestad
On Mon, 11 Mar 2024 14:15:38 GMT, Chen Liang wrote: > Looks great to me. Sorry for the pings, but we may need @rgiulietti to verify > the math correctness and @cl4es to comment on whether having these 2 separate > code paths or trying to extract a common part is the better approach. I'd love t

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v2]

2024-03-11 Thread Chen Liang
On Mon, 11 Mar 2024 13:54:06 GMT, Shaojin Wen wrote: >> The current BigDecimal(String) constructor calls String#toCharArray, which >> has a memory allocation. >> >> >> public BigDecimal(String val) { >> this(val.toCharArray(), 0, val.length()); // allocate char[] >> } >> >> >> When the l

Re: RFR: 8327791: Optimization for new BigDecimal(String) [v2]

2024-03-11 Thread Shaojin Wen
> The current BigDecimal(String) constructor calls String#toCharArray, which > has a memory allocation. > > > public BigDecimal(String val) { > this(val.toCharArray(), 0, val.length()); // allocate char[] > } > > > When the length is greater than 18, create a char[] > > > boolean isCompa

Re: RFR: 8327791: Optimization for new BigDecimal(String)

2024-03-11 Thread Chen Liang
On Sun, 10 Mar 2024 16:11:12 GMT, Shaojin Wen wrote: > The current BigDecimal(String) constructor calls String#toCharArray, which > has a memory allocation. > > > public BigDecimal(String val) { > this(val.toCharArray(), 0, val.length()); // allocate char[] > } > > > When the length is g