On Mon, 16 Oct 2023 15:00:42 GMT, Shaojin Wen <d...@openjdk.org> wrote:

>> I submitted PR #15555 before, and there were too many changes. I split it 
>> into multiple PRs with small changes. This one is one of them.
>> 
>> this PR removed the duplicate code for getChars in 
>> BigDecimal#StringBuilderHelper, i also make performance faster.
>> Please review and don't hesitate to critique my approach and patch.
>
> Shaojin Wen has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Use StringConcatFactory.makeConcatWithConstants

I have a relatively strong hypothesis: in the `StringConcatFactory` we bind in 
`String` constants in the MH expression tree, one for each argument. These 
constants may be null, which we then branch on, depending on JITs to see that 
the expression is constant and eliminate the test. Perhaps sometimes the JIT 
speculates too optimistically (thinking the constant is always null) due to 
missing profile data and then have to deoptimize and recompile in a more 
conservative mode where the dead code isn't properly eliminated. 

I have prepared a patch (#16244) which reduces the amount of branches in 
generated expression trees, which should eliminate some tripwires for the JITs. 
I'm getting more consistently good scores when running this together with the 
`"\1.\1\1"` recipe branch:


Benchmark                                 Mode  Cnt   Score   Error  Units
BigDecimals.testSmallToEngineeringString  avgt  100  11,998 ± 0,056  ns/op


Can you test this out in combination with the `"\1.\1\1"` branch and see if the 
variance improves on your setup too?

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

PR Comment: https://git.openjdk.org/jdk/pull/16006#issuecomment-1768302411

Reply via email to