RFR: 8306842: Classfile API performance improvements [v4]

Chen Liang liach at openjdk.org
Fri May 12 13:23:48 UTC 2023


On Wed, 10 May 2023 10:00:47 GMT, Adam Sotona <asotona at openjdk.org> wrote:

>> Following improvements implemented:
>> - Switch over `String` replaced with switch single char
>> - Binary search for frames in `StackMapGenerator`
>> - `StackMapGenerator.rawHandlers` with pre-calculated offsets
>> - `ClassEntry` is caching `ClassDesc` symbol
>> - Caching of type symbols in `NameAndTypeEntry` and `MethodTypeEntry`
>> - Caching `MethodTypeDesc` in `MethodInfo` implementations
>> - `StackMapGenerator` and `Utils` delegating to cached `MethodTypeDesc` instead of custom parsing
>> 
>> No API change.
>> 
>> Benchmarks show stack map generation improved by 21% and code generation from symbols improved by 30%.
>> 
>> 
>> Benchmark                     Mode  Cnt       Score       Error  Units
>> GenerateStackMaps.benchmark  thrpt   10  407931.202 ± 13101.023  ops/s
>> RebuildMethodBodies.shared   thrpt    4   10258.597 ±   383.699  ops/s
>> RebuildMethodBodies.unshared thrpt    4    7224.543 ±   256.800  ops/s
>> 
>> 
>> 
>> Benchmark                     Mode  Cnt       Score      Error  Units
>> GenerateStackMaps.benchmark  thrpt   10  495101.110 ± 2389.628  ops/s
>> RebuildMethodBodies.shared    thrpt   4   13380.272 ±  810.113  ops/s
>> RebuildMethodBodies.unshared  thrpt   4    9399.863 ±  557.060  ops/s
>
> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision:
> 
>   fixed jmh benchmark parameters

test/micro/org/openjdk/bench/jdk/classfile/RebuildMethodBodies.java line 57:

> 55:     public void setup() throws IOException {
> 56:         shared = new LinkedList<>();
> 57:         unshared = new LinkedList<>();

LinkedList should be replaced by ArrayList, as:
1. LinkedList's node wrapper around each object is too heavy, ArrayList has smaller wrapper
2. LinkedList iteration needs to follow links while ArrayList access can be machine optimized
3. ArrayList addition is amortized O(1), not really worse than LinkedList additions.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13671#discussion_r1192367198


More information about the core-libs-dev mailing list