Skip to content

Implement byte array reuse in nio transport #27563

@Tim-Brooks

Description

@Tim-Brooks

Currently, we reuse byte arrays when writing messages in the TcpTransport. We request bytes from a page recycler and serialized the message. When the message is written to the channel, a callback releases the bytes. This means that, by default, the NioTransport already includes byte array reusage for the write use case.

The read case is trickier. As read message length is unknown until a message is partially deserialized, we need some method of requesting a new byte array when we run out of space for reading. When the message has been completely read, deserialized, and dispatched, the bytes for the message can be released.

I think that we do not currently want this worked to be hooked onto BigArrays or involve circuit breakers (based on this comment by @jpountz). Instead we want to use the PageRecycler for a specific solution for the nio case.

A solution for the tcp read case would ideally generalize for future protocols.

This is related to #27260

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions