-
Enhancement
-
Resolution: Fixed
-
P4
-
None
-
b13
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
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