RFR: 8246152: Improve String concat bootstrapping

Claes Redestad claes.redestad at oracle.com
Fri May 29 15:05:19 UTC 2020


Hi,

a few small simplifications and optimizations to StringConcatFactory:

- refactor makeConcat/makeConcatWithArguments methods to remove the
   generateRecipe argument
- fold back-to-back constants into one when parsing recipe, which
   allows the prepender logic to be simplified
- do input checking in the parse pass
- get rid of the Recipe and RecipeElement classes by representing the 
parsed recipe as a list of Strings which are either null (argument slot) 
or not (constant)
- eagerly rebind on setup of those method handles that we'll always 
transform (transforming will call rebind() anyway which will now be a no-op)
- simplify filtering logic by picking up the erased type, so that we can 
do c == Object.class rather than !c.isPrimitive

Also adding a microbenchmark I used to step by step verify the fixes
having a real and measurable effect[1], while verifying a few percent
improvement on a few existing startup tests[2].

Bug:    https://bugs.openjdk.java.net/browse/JDK-8246152
Webrev: http://cr.openjdk.java.net/~redestad/8246152/open.00/

Testing: tier1

Thanks!

/Claes

[1]
java -jar build/linux-x64/images/test/micro/benchmarks.jar 
StringConcatFactoryBootstraps -f 2 -w 5 -r 5 -prof gc -jvmArgs=-Xmx1g

Before:
Benchmark Mode Cnt Score Error Units
StringConcatFactoryBootstraps.makeConcatWithConstants avgt 10 3046.855 ± 
62.981 ns/op
StringConcatFactoryBootstraps.makeConcatWithConstants:·gc.alloc.rate.norm 
avgt 10 4596.214 ± 121.121 B/op

After:
Benchmark Mode Cnt Score Error Units
StringConcatFactoryBootstraps.makeConcatWithConstants avgt 10 2764.634 ± 
56.244 ns/op
StringConcatFactoryBootstraps.makeConcatWithConstants:·gc.alloc.rate.norm 
avgt 10 4136.187 ± 0.013 B/op

[2] 
http://cr.openjdk.java.net/~redestad/scratch/erase_scf_types.00/ObjStringCombos.java

Before:
      3,661,949,568      instructions              #    1.09  insn per 
cycle           ( +-  1.04% )
        728,280,499      branches                  #  492.540 M/sec 
               ( +-  1.06% )
         30,496,964      branch-misses             #    4.19% of all 
branches          ( +-  0.93% )

        0.301502707 seconds time elapsed 
          ( +-  1.04% )

After:
      3,485,679,714      instructions              #    1.09  insn per 
cycle           ( +-  0.90% )
        692,247,529      branches                  #  491.822 M/sec 
               ( +-  0.92% )
         28,939,534      branch-misses             #    4.18% of all 
branches          ( +-  0.90% )

        0.291642667 seconds time elapsed 
          ( +-  0.93% )



More information about the core-libs-dev mailing list