RFR: 8338532: Speed up the ClassFile API MethodTypeDesc#ofDescriptor
Chen Liang
liach at openjdk.org
Mon Aug 19 06:32:24 UTC 2024
On Mon, 19 Aug 2024 00:46:13 GMT, Chen Liang <liach at openjdk.org> wrote:
>> src/java.base/share/classes/jdk/internal/constant/ConstantUtils.java line 296:
>>
>>> 294: // objectDesc appears a lot during the bootstrap process, so optimize it
>>> 295: String objectDesc = "Ljava/lang/Object;";
>>> 296: if (len == objectDesc.length() && descriptor.regionMatches(start, objectDesc, 0, len)) {
>>
>> Note that from my bytestack investigations, `regionMatches` can be CPU-intensive like hashCode calculation. Running this trick against `Ljava/lang/String;` (same length) might cause a lot of misses and waste a lot of CPU time. Can you try on a case with many `Ljava/lang/String;` descriptors and see the results compared to the build without this special case?
>
> Also `Double` `Module` `Number` `Record` `Thread` `System` are susceptible to taking more time in `regionMatches`.
I think you can have the current patch RFR (ready for review) without this deduplication given my concerns. We can add deduplication of frequent descriptors in another patch after confirming it is a net positive.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20611#discussion_r1721132965
More information about the core-libs-dev
mailing list