Integrated: 8268622: Performance issues in javac `Name` class

Archie Cobbs acobbs at openjdk.org
Mon Oct 2 20:56:44 UTC 2023


On Tue, 29 Aug 2023 15:38:05 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:

> Quoting [JDK-8268622](https://bugs.openjdk.org/browse/JDK-8268622):
>> The javadoc team has identified performance issues in the javac `Name` class, particularly when it is used via its `CharSequence` interface ([JDK-8263321](https://bugs.openjdk.org/browse/JDK-8263321)). The main issue there is that the `CharSequence` is specifically character-oriented, whereas the native form inside javac is a byte[] in modified-UTF8 form. Operations like `.length()` and `.charAt(int)` have "simple" but very inefficient implementations.
> 
> Thanks to [JDK-8269957](https://bugs.openjdk.org/browse/JDK-8269957) we now have the option to swap in a `String`-based `Name` table implementation in place of the current UTF-8-based one. This does in fact improve performance of the compiler.
> 
> This patch does two things:
> * Make the `String`-based `Name` table implementation the default. The two other UTF-8-based implementations are still available via the flags `-XDuseUnsharedTable=true` and `-XDuseSharedTable=true` (the latter was the previous default). This results in a 19% speedup in my simple benchmark (see below).
> * Adds a new flag `-XDinternStringTable=true`, which turns on `intern()`ing of the `String`s in the `String` table. This however is **not** the default because it results in lower performance (see below). But it's possible this could help in other scenarios so it's left in there for future testing purposes.
> 
> Here are results from the [JavacNameTable.java](https://github.com/openjdk/jdk/files/12466359/JavacNameTable.java.txt) benchmark.
> 
> Benchmark                             Mode  Cnt   Score   Error  Units
> JavacNameTable.testSharedTable        avgt   25  54.145 ± 1.738  ms/op
> JavacNameTable.testStringTable        avgt   25  45.305 ± 0.415  ms/op
> JavacNameTable.testStringTableIntern  avgt   25  50.736 ± 0.245  ms/op
> JavacNameTable.testUnsharedTable      avgt   25  59.877 ± 2.503  ms/op
> 
> To reiterate: `testSharedTable` reflects the previous default; `testStringTable` reflects the new default. The other two options are available via the flags `-XDinternStringTable=true` and `-XDuseUnsharedTable=true`.

This pull request has now been integrated.

Changeset: 5c8366ee
Author:    Archie Cobbs <acobbs at openjdk.org>
Committer: Vicente Romero <vromero at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/5c8366eea4555b5b145a5337e774020006e00db9
Stats:     18 lines in 2 files changed: 6 ins; 3 del; 9 mod

8268622: Performance issues in javac `Name` class

Reviewed-by: vromero

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

PR: https://git.openjdk.org/jdk/pull/15470


More information about the compiler-dev mailing list