RFR: 8338546: Speed up ConstantPoolBuilder::classEntry(ClassDesc) [v3]

Chen Liang liach at openjdk.org
Tue Sep 17 02:41:14 UTC 2024


On Tue, 17 Sep 2024 02:04:51 GMT, Chen Liang <liach at openjdk.org> wrote:

>> Speed up `ConstantPoolBuilder::classEntry(ClassDesc)` by going through `ClassDesc` comparison and reusing descriptor hash to calculate internal name hash if possible. No suitable device to run benchmarks so need to find something to run the new benchmark to ensure things work as intended.
>
> Chen Liang has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 15 commits:
> 
>  - Fix build
>  - Merge branch 'master' of https://github.com/openjdk/jdk into feature/classentry-speedup
>  - Buggy 2nd attempt - crashes hotspot
>  - Merge branch 'master' of https://github.com/openjdk/jdk into feature/classentry-speedup
>  - Merge branch 'master' of https://github.com/openjdk/jdk into feature/classentry-speedup
>  - More conflicts
>  - Merge branch 'master' of https://github.com/openjdk/jdk into feature/classentry-speedup
>  - Merge branch 'master' of https://github.com/openjdk/jdk into feature/classentry-speedup
>  - Merge branch 'master' of https://github.com/openjdk/jdk into feature/classentry-speedup
>  - Another bug in benchmark
>  - ... and 5 more: https://git.openjdk.org/jdk/compare/996790c7...6117a5bd

Current benchmark numbers:
Baseline:

Benchmark                                           Mode  Cnt     Score     Error   Units
ConstantPoolBuildingClassEntry.identicalLookup     thrpt    5   649.643 ±   5.226  ops/ms
ConstantPoolBuildingClassEntry.internalNameLookup  thrpt    5  2389.365 ± 382.997  ops/ms
ConstantPoolBuildingClassEntry.nonIdenticalLookup  thrpt    5   650.280 ±   3.360  ops/ms
ConstantPoolBuildingClassEntry.oldStyleLookup      thrpt    5   695.891 ±  10.246  ops/ms

Patch:

Benchmark                                           Mode  Cnt     Score     Error   Units
ConstantPoolBuildingClassEntry.identicalLookup     thrpt    5  2394.541 ± 148.267  ops/ms  268.59%
ConstantPoolBuildingClassEntry.internalNameLookup  thrpt    5  1506.351 ±  21.757  ops/ms  -36.96%
ConstantPoolBuildingClassEntry.nonIdenticalLookup  thrpt    5  1908.198 ±  31.008  ops/ms  193.44%
ConstantPoolBuildingClassEntry.oldStyleLookup      thrpt    5   545.962 ±  10.603  ops/ms  -21.54%


In short, this patch is based on the assumption that ClassEntry lookup via `ClassDesc` is way more prevalent than that via a `Utf8Entry`; this is true for JDK and we would recommend all ClassFile API users to follow suit of using pre-validated symbols.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/20667#issuecomment-2354390268


More information about the core-libs-dev mailing list