JDK-8352891 Performance improvements to ByteArrayOutputStream

Engebretson, John jengebr at amazon.com
Fri Apr 11 15:50:03 UTC 2025


I would like to see JDK standard "array builders" for primitive types and reference types that use fixed sized (power-of-two) segments internally.

I want to caution on the power-of-two idea – it leads to large objects faster than the current implementation, which hurts performance as well as max capacity.  There is value in fixed-size options but we would want something with a slower rate of growth.

The "underlying problem" that I think should be addressed by some new internal class (or suite of classes) is the "array builder" problem. This is where you're doing "append, append, append, ..., use read-only thereafter".

I would prefer targeting a few, common use cases – ByteArrayOutputStream is the example that got us here. Optimizing forward-only handling is an easy starting place and we can always add on later.
    John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20250411/f0a7d9f0/attachment.htm>


More information about the core-libs-dev mailing list