Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8273100

Improve AbstractStringBuilder.append(String) when using CompactStrings

    XMLWordPrintable

Details

    • Enhancement
    • Status: Resolved
    • P4
    • Resolution: Fixed
    • None
    • 18
    • core-libs
    • b13

    Description

      A few StringBuilders microbenchmarks show a minor throughput penalty when running with CompactStrings (default) vs witout it, even though the allocation much lower in the former case.

      Analyzing profiles it seems that a few methods aren't inlined optimally when CompactStrings is enabled, which means some redundant checks aren't eliminated.

      18-b09 -CompactStrings
      Benchmark Mode Cnt Score Error Units
      StringBuilders.appendLoop16 avgt 25 716.850 ± 7.857 ns/op
      StringBuilders.appendLoop8 avgt 25 374.279 ± 5.793 ns/op

      18-b09 +CompactStrings
      Benchmark Mode Cnt Score Error Units
      StringBuilders.appendLoop16 avgt 25 749.861 ± 6.717 ns/op
      StringBuilders.appendLoop8 avgt 25 382.491 ± 4.603 ns/op

      The patch I have in mind eliminates much of the relative overhead without negatively affecting -CompactStrings, and is also a 15-20% win when running in the interpreter:

      Benchmark Mode Cnt Score Error Units
      StringBuilders.appendLoop16 avgt 25 724.803 ± 9.613 ns/op
      StringBuilders.appendLoop8 avgt 25 374.400 ± 6.368 ns/op

      Attachments

        Issue Links

          Activity

            People

              redestad Claes Redestad
              redestad Claes Redestad
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: