RFR: 8260053: Optimize Tokens' use of Names
Guoxiong Li
github.com+13688759+lgxbslgx at openjdk.java.net
Thu Jan 21 18:44:56 UTC 2021
On Thu, 21 Jan 2021 11:21:21 GMT, Guoxiong Li <github.com+13688759+lgxbslgx at openjdk.org> wrote:
>> Hi all,
>>
>> This patch initializes the names about `TokenKind` at the beginning of the constructor of the class `Names`. As a result, the `Tokens.maxKey` and the length of the array `Tokens.key` become small. By using this patch, the length of the array `Tokens.key` is changed from 4280 to 383.
>>
>> The original discussion is at [compiler-dev](https://mail.openjdk.java.net/pipermail/compiler-dev/2021-January/016126.html).
>>
>> Thank you for taking the time to review.
>>
>> Best Regards.
>
> Thanks for your comments.
>
> My patch mainly focused on using less memory without causing performance degradation. But I lacked consideration about the architecture which is also important. I agree with you that the utility classes should not dependent on other classes.
>
> Using `Map<String, TokenKind>` instead of `TokenKind[]` looks like a good idea. It reduces the memory and doesn't revise the class `Names`. But the more important aspect is that it can't cause performance regression. I will do some benchmark test by using `Map<String, TokenKind>` locally to observe the performance and will share the result with you.
I updated the code by using `Map<String, TokenKind>`.
And I found the related benchmark is already at [jmh-jdk-microbenchmarks](https://github.com/openjdk/jmh-jdk-microbenchmarks). When I built the code of this `jmh-jdk-microbenchmarks` project locally, I could not get the result over 5 hours which made me give up. The build output is shown below. Many `......` are at the end of the output which I don't paste it here.
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< org.openjdk:micros-javac >----------------------
[INFO] Building OpenJDK Microbenchmark of Java Compile 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ micros-javac ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/lgx/source/java/jmh-jdk-microbenchmarks/micros-javac/src/main/resources
[INFO]
[INFO] --- maven-antrun-plugin:1.8:run (default) @ micros-javac ---
[INFO] Executing tasks
main:
[mkdir] Created dir: /home/lgx/source/java/jmh-jdk-microbenchmarks/micros-javac/target/classes
[get] Getting: https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_windows-x64_bin.zip
[get] To: /home/lgx/source/java/jmh-jdk-microbenchmarks/micros-javac/target/jdk-bin.zip
.............................................................................................................. // many ......
Could I get your help to try to build and run the benchmark locally?
Or could the JMH team help to run the test? Thanks a lot.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2169
More information about the compiler-dev
mailing list