Re: RFR: 8316426: Optimization for HexFormat.formatHex [v10]

2023-10-12 Thread Claes Redestad
On Fri, 6 Oct 2023 17:06:08 GMT, Shaojin Wen wrote: >> In the improvement of @cl4es PR #15591, the advantages of non-lookup-table >> were discussed. >> >> But if the input is byte[], using lookup table can improve performance. >> >> For HexFormat#formatHex(Appendable, byte[]) and HexFormat#for

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v9]

2023-10-11 Thread Shaojin Wen
On Fri, 6 Oct 2023 14:20:13 GMT, Claes Redestad wrote: >> Shaojin Wen has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Update full name > > FWIW I'll not review or sponsor any PRs that use `ByteArrayLittleEndian` for > trivial `byte[]` w

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v9]

2023-10-06 Thread 温绍锦
On Fri, 6 Oct 2023 14:20:13 GMT, Claes Redestad wrote: > FWIW I'll not review or sponsor any PRs that use `ByteArrayLittleEndian` for > trivial `byte[]` writes until there's been a thorough analysis of why this > helps and shown that JITs can't be expected to generate code that is as > optimal

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v10]

2023-10-06 Thread 温绍锦
> In the improvement of @cl4es PR #15591, the advantages of non-lookup-table > were discussed. > > But if the input is byte[], using lookup table can improve performance. > > For HexFormat#formatHex(Appendable, byte[]) and HexFormat#formatHex(byte[]), > If the length of byte[] is larger, the pe

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v9]

2023-10-06 Thread Claes Redestad
On Fri, 29 Sep 2023 20:03:09 GMT, 温绍锦 wrote: >> In the improvement of @cl4es PR #15591, the advantages of non-lookup-table >> were discussed. >> >> But if the input is byte[], using lookup table can improve performance. >> >> For HexFormat#formatHex(Appendable, byte[]) and HexFormat#formatHex(

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v8]

2023-10-06 Thread 温绍锦
On Wed, 27 Sep 2023 13:35:55 GMT, Roger Riggs wrote: >> 温绍锦 has updated the pull request incrementally with one additional commit >> since the last revision: >> >> reduce the size of HexFormat##DIGITS, from 256 to 128 > > It is conventional to get re-reviews of any change and give the reviewe

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v9]

2023-09-29 Thread 温绍锦
> In the improvement of @cl4es PR #15591, the advantages of non-lookup-table > were discussed. > > But if the input is byte[], using lookup table can improve performance. > > For HexFormat#formatHex(Appendable, byte[]) and HexFormat#formatHex(byte[]), > If the length of byte[] is larger, the pe

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v8]

2023-09-27 Thread Roger Riggs
On Wed, 27 Sep 2023 09:07:44 GMT, 温绍锦 wrote: >> In the improvement of @cl4es PR #15591, the advantages of non-lookup-table >> were discussed. >> >> But if the input is byte[], using lookup table can improve performance. >> >> For HexFormat#formatHex(Appendable, byte[]) and HexFormat#formatHex(

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v8]

2023-09-27 Thread 温绍锦
> In the improvement of @cl4es PR #15591, the advantages of non-lookup-table > were discussed. > > But if the input is byte[], using lookup table can improve performance. > > For HexFormat#formatHex(Appendable, byte[]) and HexFormat#formatHex(byte[]), > If the length of byte[] is larger, the pe

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v7]

2023-09-27 Thread 温绍锦
On Wed, 27 Sep 2023 04:16:11 GMT, Roger Riggs wrote: > ok, but perhaps you can shrink it further, if it does not hurt performance, > by subtracting 0x20 before indexing and cut the table to 64 bytes. If you use DIGITS of size 54, performance will be 10% slower, The code is written like this:

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v7]

2023-09-26 Thread Roger Riggs
On Tue, 19 Sep 2023 14:30:18 GMT, 温绍锦 wrote: >> In the improvement of @cl4es PR #15591, the advantages of non-lookup-table >> were discussed. >> >> But if the input is byte[], using lookup table can improve performance. >> >> For HexFormat#formatHex(Appendable, byte[]) and HexFormat#formatHex(

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v7]

2023-09-26 Thread 温绍锦
On Tue, 19 Sep 2023 14:30:18 GMT, 温绍锦 wrote: >> In the improvement of @cl4es PR #15591, the advantages of non-lookup-table >> were discussed. >> >> But if the input is byte[], using lookup table can improve performance. >> >> For HexFormat#formatHex(Appendable, byte[]) and HexFormat#formatHex(

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v7]

2023-09-26 Thread Roger Riggs
On Tue, 19 Sep 2023 14:30:18 GMT, 温绍锦 wrote: >> In the improvement of @cl4es PR #15591, the advantages of non-lookup-table >> were discussed. >> >> But if the input is byte[], using lookup table can improve performance. >> >> For HexFormat#formatHex(Appendable, byte[]) and HexFormat#formatHex(

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v7]

2023-09-19 Thread 温绍锦
> In the improvement of @cl4es PR #15591, the advantages of non-lookup-table > were discussed. > > But if the input is byte[], using lookup table can improve performance. > > For HexFormat#formatHex(Appendable, byte[]) and HexFormat#formatHex(byte[]), > If the length of byte[] is larger, the pe

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v6]

2023-09-19 Thread Roger Riggs
On Tue, 19 Sep 2023 10:41:51 GMT, 温绍锦 wrote: >> In the improvement of @cl4es PR #15591, the advantages of non-lookup-table >> were discussed. >> >> But if the input is byte[], using lookup table can improve performance. >> >> For HexFormat#formatHex(Appendable, byte[]) and HexFormat#formatHex(

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v6]

2023-09-19 Thread Roger Riggs
On Tue, 19 Sep 2023 01:35:49 GMT, 温绍锦 wrote: >> The original (and current) is coded to avoid a condition inside the loop. > > I also think that the way of writing for_0 combined with if > 0 is easier to > understand, The operation overhead of if > 0 is very small, and it will not > affect perfo

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v4]

2023-09-19 Thread 温绍锦
On Tue, 19 Sep 2023 10:26:50 GMT, 温绍锦 wrote: >> If we changed DIGITS to be encoded with the uppercase digits then the >> expression could be simplified to >> ```return ucase ? v : (short) (v | 0b0010__0010_); // or 0x2020``` > > Some performance-focused scenarios, such as UUID.toString,

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v6]

2023-09-19 Thread 温绍锦
> In the improvement of @cl4es PR #15591, the advantages of non-lookup-table > were discussed. > > But if the input is byte[], using lookup table can improve performance. > > For HexFormat#formatHex(Appendable, byte[]) and HexFormat#formatHex(byte[]), > If the length of byte[] is larger, the pe

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v5]

2023-09-19 Thread 温绍锦
> In the improvement of @cl4es PR #15591, the advantages of non-lookup-table > were discussed. > > But if the input is byte[], using lookup table can improve performance. > > For HexFormat#formatHex(Appendable, byte[]) and HexFormat#formatHex(byte[]), > If the length of byte[] is larger, the pe

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v4]

2023-09-19 Thread 温绍锦
On Tue, 19 Sep 2023 09:34:56 GMT, Claes Redestad wrote: >> src/java.base/share/classes/jdk/internal/util/HexDigits.java line 103: >> >>> 101: short v = DIGITS[i & 0xff]; >>> 102: return ucase >>> 103: ? (short) (v - ((v & 0b0100__0100_) >> 1)) // >>> real

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v4]

2023-09-19 Thread Claes Redestad
On Tue, 19 Sep 2023 09:25:36 GMT, Chen Liang wrote: >> 温绍锦 has updated the pull request incrementally with one additional commit >> since the last revision: >> >> "-" -> "& ~" > > src/java.base/share/classes/jdk/internal/util/HexDigits.java line 103: > >> 101: short v = DIGITS[i & 0x

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v4]

2023-09-19 Thread Chen Liang
On Tue, 19 Sep 2023 09:03:35 GMT, 温绍锦 wrote: >> In the improvement of @cl4es PR #15591, the advantages of non-lookup-table >> were discussed. >> >> But if the input is byte[], using lookup table can improve performance. >> >> For HexFormat#formatHex(Appendable, byte[]) and HexFormat#formatHex(

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v4]

2023-09-19 Thread 温绍锦
> In the improvement of @cl4es PR #15591, the advantages of non-lookup-table > were discussed. > > But if the input is byte[], using lookup table can improve performance. > > For HexFormat#formatHex(Appendable, byte[]) and HexFormat#formatHex(byte[]), > If the length of byte[] is larger, the pe

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v3]

2023-09-19 Thread 温绍锦
> In the improvement of @cl4es PR #15591, the advantages of non-lookup-table > were discussed. > > But if the input is byte[], using lookup table can improve performance. > > For HexFormat#formatHex(Appendable, byte[]) and HexFormat#formatHex(byte[]), > If the length of byte[] is larger, the pe

Re: RFR: 8316426: Optimization for HexFormat.formatHex

2023-09-18 Thread 温绍锦
On Mon, 18 Sep 2023 17:18:29 GMT, Roger Riggs wrote: > > HexDecimal#DIGITS is a table with a size of 512 bytes. I think that in such > > a table, when it needs to be used continuously, it is worthwhile to perform > > table lookup operations. > > HexFormat was designed for presenting bytes to h

Re: RFR: 8316426: Optimization for HexFormat.formatHex [v2]

2023-09-18 Thread 温绍锦
> In the improvement of @cl4es PR #15591, the advantages of non-lookup-table > were discussed. > > But if the input is byte[], using lookup table can improve performance. > > For HexFormat#formatHex(Appendable, byte[]) and HexFormat#formatHex(byte[]), > If the length of byte[] is larger, the pe

Re: RFR: 8316426: Optimization for HexFormat.formatHex

2023-09-18 Thread 温绍锦
On Mon, 18 Sep 2023 19:08:14 GMT, Roger Riggs wrote: >> src/java.base/share/classes/java/util/HexFormat.java line 422: >> >>> 420: toHexDigits(out, bytes[fromIndex + i]); >>> 421: } >>> 422: out.append(suffix); >> >> Maybe change t

Re: RFR: 8316426: Optimization for HexFormat.formatHex

2023-09-18 Thread Roger Riggs
On Fri, 15 Sep 2023 18:04:29 GMT, 温绍锦 wrote: > In the improvement of @cl4es PR #15591, the advantages of non-lookup-table > were discussed. > > But if the input is byte[], using lookup table can improve performance. > > For HexFormat#formatHex(Appendable, byte[]) and HexFormat#formatHex(byte[]

Re: RFR: 8316426: Optimization for HexFormat.formatHex

2023-09-18 Thread Roger Riggs
On Mon, 18 Sep 2023 13:40:48 GMT, Chen Liang wrote: >> In the improvement of @cl4es PR #15591, the advantages of non-lookup-table >> were discussed. >> >> But if the input is byte[], using lookup table can improve performance. >> >> For HexFormat#formatHex(Appendable, byte[]) and HexFormat#for

Re: RFR: 8316426: Optimization for HexFormat.formatHex

2023-09-18 Thread Roger Riggs
On Fri, 15 Sep 2023 22:19:53 GMT, 温绍锦 wrote: > HexDecimal#DIGITS is a table with a size of 512 bytes. I think that in such a > table, when it needs to be used continuously, it is worthwhile to perform > table lookup operations. HexFormat was designed for presenting bytes to humans, typical lin

Re: RFR: 8316426: Optimization for HexFormat.formatHex

2023-09-18 Thread Claes Redestad
On Mon, 18 Sep 2023 13:51:06 GMT, Chen Liang wrote: >> In the improvement of @cl4es PR #15591, the advantages of non-lookup-table >> were discussed. >> >> But if the input is byte[], using lookup table can improve performance. >> >> For HexFormat#formatHex(Appendable, byte[]) and HexFormat#for

Re: RFR: 8316426: Optimization for HexFormat.formatHex

2023-09-18 Thread Claes Redestad
On Fri, 15 Sep 2023 19:11:48 GMT, 温绍锦 wrote: > The byte[] length used by HexFormatBench is 512. In this scenario, the > performance improvement of using table lookup is significant. Is this a common use-case? I could see an argument that formatting small chunks is much more common, where users

Re: RFR: 8316426: Optimization for HexFormat.formatHex

2023-09-18 Thread 温绍锦
On Fri, 15 Sep 2023 18:04:29 GMT, 温绍锦 wrote: > In the improvement of @cl4es PR #15591, the advantages of non-lookup-table > were discussed. > > But if the input is byte[], using lookup table can improve performance. > > For HexFormat#formatHex(Appendable, byte[]) and HexFormat#formatHex(byte[]

RFR: 8316426: Optimization for HexFormat.formatHex

2023-09-18 Thread 温绍锦
In the improvement of @cl4es PR #15591, the advantages of non-lookup-table were discussed. But if the input is byte[], using lookup table can improve performance. For HexFormat#formatHex(Appendable, byte[]) and HexFormat#formatHex(byte[]), If the length of byte[] is larger, the performance of t

Re: RFR: 8316426: Optimization for HexFormat.formatHex

2023-09-18 Thread 温绍锦
On Fri, 15 Sep 2023 18:20:32 GMT, Claes Redestad wrote: > What numbers do you get with this? > > In my experiments the improvement was either negligible or small enough to > hardly matter. I also tried flipping bits similar to what you're doing for > uppercasing but saw a net regression from t

Re: RFR: 8316426: Optimization for HexFormat.formatHex

2023-09-18 Thread Claes Redestad
On Fri, 15 Sep 2023 18:04:29 GMT, 温绍锦 wrote: > In the improvement of @cl4es PR #15591, the advantages of non-lookup-table > were discussed. > > But if the input is byte[], using lookup table can improve performance. > > For HexFormat#formatHex(Appendable, byte[]) and HexFormat#formatHex(byte[]

Re: RFR: 8316426: Optimization for HexFormat.formatHex

2023-09-18 Thread Chen Liang
On Fri, 15 Sep 2023 18:04:29 GMT, 温绍锦 wrote: > In the improvement of @cl4es PR #15591, the advantages of non-lookup-table > were discussed. > > But if the input is byte[], using lookup table can improve performance. > > For HexFormat#formatHex(Appendable, byte[]) and HexFormat#formatHex(byte[]