RFR: 8321620: Optimize JImage decompressors
Glavo
duke at openjdk.org
Fri Dec 8 22:43:43 UTC 2023
On Thu, 9 Nov 2023 02:07:57 GMT, Chen Liang <liach at openjdk.org> wrote:
>> This PR significantly speeds up decompressing resources in Jimage while significantly reducing temporary memory allocations in the process.
>>
>> This will improve startup speed for runtime images generated using `jlink --compress 1` and `jlink --compress 2` .
>>
>> I generated a runtime image containing javac using `jlink --compress 1 --add-modules jdk.compiler` and tested the time it took to compile a simple HelloWorld program 20 times using `perf stat -r20 javac /dev/shm/HelloWorld.java`, this PR reduces the total time taken from 17830ms to 13598ms (31.12% faster).
>
> src/java.base/share/classes/jdk/internal/jimage/decompressor/StringSharingDecompressor.java line 111:
>
>> 109: int count = Short.toUnsignedInt(bytesIn.getShort());
>> 110: bytesOut[bytesOutOffset++] = (byte) ((count >> 8) & 0xff);
>> 111: bytesOut[bytesOutOffset++] = (byte) (count & 0xff);
>
> Probably use `ByteArray.setUnsignedShort`:
> Suggestion:
>
> ByteArray.setUnsignedShort(bytesOut, bytesOutOffset, count);
> bytesOutOffset += 2;
>
> Same remark elsewhere.
These classes need to be compiled with `--release 8`, so I can't use the `ByteArray`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16556#discussion_r1387837310
More information about the core-libs-dev
mailing list