On Tue, 14 May 2024 20:20:59 GMT, Chen Liang <[email protected]> wrote:
>> Claes Redestad has updated the pull request incrementally with one
>> additional commit since the last revision:
>>
>> Add microbenchmark for ClassDesc methods + a few optimizations
>
> src/java.base/share/classes/java/lang/constant/ClassDesc.java line 226:
>
>> 224: for (int i = 0; i < rank; i++) {
>> 225: sb.append('[');
>> 226: }
>
> Would `sb.repeat("[", rank);` be better here?
>
> Also for parity with `arrayType()` I recommend moving this building code to
> after the void check.
Oh, that's new (in 21). I was comparing against `append("[".repeat(rank))`
which had a cost here. `sb.repeat('[', rank)` is in the same ballpark and
simpler. Fixing.
Benchmark Mode Cnt Score Error
Units
ClassDescMethods.arrayType2 avgt 15 31,568 ± 2,108
ns/op
ClassDescMethods.arrayType2:gc.alloc.rate avgt 15 7758,056 ± 474,378
MB/sec
ClassDescMethods.arrayType2:gc.alloc.rate.norm avgt 15 256,000 ± 0,001
B/op
I'll align the code to construct `newDesc` before the void check in both
methods.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/19105#discussion_r1601088246