When generating `MethodHandle`-based concatenation expressions in 
`StringConcatFactory` we can reduce the number of classes generated at runtime 
by creating small batches of prependers and mixers before binding them into the 
root expression tree. 

Improvements on one-off tests are modest, while the improvement on 
bootstrapping stress tests can be substantial 
([MixedStringCombinations.java](https://gist.github.com/cl4es/08fb581dece3a73e89bfa52337bc4248)):

| Build      |    # classes    |   Runtime   |
| ----------- | ----------------- |  --------------- |
| Baseline |     31119       |     2.942s     |
| Patch      |     16208       |     1.958s     |

An earlier version of this patch saw a regression in the 
`StringConcatFactoryBootstraps` microbenchmark. After some refactoring along 
with the optimizations in #8881 and #8923 that is no longer the case, and 
allocation pressure is down slightly compared to the baseline on such a 
repeat-the-same-bootstrap stress test:

Baseline:

Benchmark                                                      Mode  Cnt     
Score      Error   Units
SCFB.makeConcatWithConstants                                   avgt    5  
2170.039 ?  117.441   ns/op
SCFB.makeConcatWithConstants:?gc.alloc.rate.norm               avgt    5  
3538.020 ?    4.558    B/op

This patch:

Benchmark                                                      Mode  Cnt     
Score      Error   Units
SCFB.makeConcatWithConstants                                   avgt    5  
2144.807 ?  162.685   ns/op
SCFB.makeConcatWithConstants:?gc.alloc.rate.norm               avgt    5  
3184.943 ?    4.495    B/op

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

Commit messages:
 - Revert change to HelloClasslist (doesn't affect generation)
 - Reduce allocation adding in mixers by extracting constant arg lists and 
caching double arg mixers
 - De-CHM the prepender and mixer caches
 - Reduce allocations: Extract constant argument lists, cache base form for 
two-arg prependers
 - Refactor, reduce allocations
 - Merge branch 'master' into scf_chunked
 - Improve chunking further
 - Fix mis-merged change
 - Experiment: Chunk prependers and mixers to reduce number of rebinds and 
generated LF classes

Changes: https://git.openjdk.java.net/jdk/pull/8855/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=8855&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8287522
  Stats: 390 lines in 2 files changed: 232 ins; 99 del; 59 mod
  Patch: https://git.openjdk.java.net/jdk/pull/8855.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/8855/head:pull/8855

PR: https://git.openjdk.java.net/jdk/pull/8855

Reply via email to