Integrated: 8261743: Shenandoah: enable String deduplication with compact heuristics
Rui Li
duke at openjdk.org
Thu Nov 6 23:50:13 UTC 2025
On Thu, 6 Nov 2025 01:38:36 GMT, Rui Li <duke at openjdk.org> wrote:
> Enable `UseStringDeduplication` when using compact heuristics.
>
> Testing:
>
> ./build/macosx-aarch64-server-release/images/jdk/bin/java -XX:+UseShenandoahGC -XX:+UnlockDiagnosticVMOptions -XX:ShenandoahGCHeuristics=compact -XX:+PrintFlagsFinal --version | grep UseStringDeduplication
> bool UseStringDeduplication = true {product} {default}
>
>
> Note: The labels should be `{product} {ergonomic}` ideally. Pending on a separate issue: [JDK-8371381](https://bugs.openjdk.org/browse/JDK-8371381)
>
>
> -------
>
> Edit: add benchmark results:
>
> Had a simple benchmark below (credit to [here](https://muratakkan.medium.com/understanding-string-deduplication-in-java-how-it-works-and-when-to-use-it-fbda71711435)):
>
>
>
> @Benchmark
> public void testMethod(Blackhole bh) {
> String[] strings = new String[1000000];
> for (int i = 0; i < strings.length; i++) {
> strings[i] = "This is a test string";
> }
> bh.consume(strings);
> }
>
>
> Results:
>
> ########
> java -jar target/benchmarks.jar --jvmArgs "-XX:-UseStringDeduplication -XX:+UseShenandoahGC -XX:+UnlockDiagnosticVMOptions -XX:ShenandoahGCHeuristics=compact" -prof gc
> ########
> Benchmark Mode Cnt Score Error Units
> MyBenchmark.testMethod thrpt 3 3181.651 ± 248.835 ops/s
> MyBenchmark.testMethod:gc.alloc.rate thrpt 3 12136.888 ± 949.185 MB/sec
> MyBenchmark.testMethod:gc.alloc.rate.norm thrpt 3 4000016.188 ± 0.016 B/op
> MyBenchmark.testMethod:gc.count thrpt 3 1568.000 counts
> MyBenchmark.testMethod:gc.time thrpt 3 1882.000 ms
>
> ########
> java -jar target/benchmarks.jar --jvmArgs "-XX:+UseShenandoahGC -XX:+UnlockDiagnosticVMOptions -XX:ShenandoahGCHeuristics=compact" -prof gc
> ########
> Benchmark Mode Cnt Score Error Units
> MyBenchmark.testMethod thrpt 3 3155.961 ± 365.174 ops/s # throuput decreased by 0.8%
> MyBenchmark.testMethod:gc.alloc.rate thrpt 3 12038.882 ± 1394.186 MB/sec # decreased by 0.8%
> MyBenchmark.testMethod:gc.alloc.rate.norm thrpt 3 4000016.190 ± 0.022 B/op # same
> MyBenchmark.testMethod:gc.count thrpt 3 1172.000 counts # decreased by 25%
> MyBenchmark.testMethod:gc.time thrpt 3 726.000 ms # decrea...
This pull request has now been integrated.
Changeset: e34a8318
Author: Rui Li <ruiamzn at amazon.com>
Committer: Xiaolong Peng <xpeng at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/e34a831814996be3e0a2df86b11b1718a76ea558
Stats: 1 line in 1 file changed: 1 ins; 0 del; 0 mod
8261743: Shenandoah: enable String deduplication with compact heuristics
Reviewed-by: shade, wkemper
-------------
PR: https://git.openjdk.org/jdk/pull/28170
More information about the hotspot-gc-dev
mailing list