RFR: 8261743: Shenandoah: enable String deduplication with compact heuristics

duke duke at openjdk.org
Thu Nov 6 22:35:09 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...

@rgithubli 
Your change (at version 2407976e137e42f3f831690c14501b0e338a4c4e) is now ready to be sponsored by a Committer.

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

PR Comment: https://git.openjdk.org/jdk/pull/28170#issuecomment-3499636944


More information about the hotspot-gc-dev mailing list