RFR: 8315585: Optimization for decimal to string [v6]

Claes Redestad redestad at openjdk.org
Sun Oct 15 17:57:28 UTC 2023


On Fri, 13 Oct 2023 17:01:11 GMT, Shaojin Wen <duke at 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 % calculate lowInt

I don't have anything in principle against moving `stringSize` to `j.u.DecimalDigits` as it doesn't leak information about internal `String` encoding, but we need to be very careful about exposing implementation details of `StringLatin1/StringUTF16` and leaning on such details, even internally, since it increase the risk for subtle bugs and increases maintenance overheads. The bar for exposing internals via JLA or even moving them to `jdk.internal.util` classes needs to be very high.

I'd say go with what you have now:  once we enable compiling `java.math.BigDecimals` so that string concatenation uses `StringConcatFactory` then peak performance should improve. The only reasonable alternative in my mind is to revert changes for this branch entirely (reinstating the `StringBuilderHelper` etc) and revisit this once we have a solution that ensures both better performance and simpler code.

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

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


More information about the core-libs-dev mailing list