RFR: 8378698: Optimize Base64.Encoder#encodeToString

Alan Bateman alanb at openjdk.org
Thu Feb 26 07:36:18 UTC 2026


On Wed, 25 Feb 2026 20:08:19 GMT, Patrick Strawderman <duke at openjdk.org> wrote:

>> Hmm, I checked the code of that deprecated constructor. If the compiler can recognize `count == ascii.length` then it should be able to fold this code; maybe the compiler is too stupid. Have you verified the performance results in a benchmark?
>
>> Hmm, I checked the code of that deprecated constructor. If the compiler can recognize `count == ascii.length` then it should be able to fold this code; maybe the compiler is too stupid. Have you verified the performance results in a benchmark?
> 
> I did not run benchmarks, just saw that the constructor copies the array (obviously since it's public), and that we use JLA in other places to avoid the copy.
> 
>> Turns out this is necessary per https://bugs.openjdk.org/browse/JDK-8364418
> 
> Yep I saw that as well, which is why I thought this would be beneficial.

@kilink Are you going to update the PR with the performance data and a summary of the testing that you have done? Are the benchmarks for Base64.Encoder in test/micro sufficient or will this PR propose to add more benchmarks?

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

PR Comment: https://git.openjdk.org/jdk/pull/29920#issuecomment-3964695824


More information about the core-libs-dev mailing list