Skip to content

Grow byte buffers as data is read in read_xdr - #650

Open
leighmcculloch wants to merge 4 commits into
mainfrom
make-byte-reads-allocate-proportionally
Open

leighmcculloch wants to merge 4 commits into
mainfrom
make-byte-reads-allocate-proportionally

Conversation

@leighmcculloch

@leighmcculloch leighmcculloch commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

What

Make the ReadXdr impls for VecM<u8>, BytesM and StringM grow their buffer as bytes arrive instead of allocating the declared length before reading the body.

Why

A 4-byte length prefix could make these readers allocate up to ~4 GiB even when the input holds only a few bytes, so allocation now stays proportional to the input actually received (#623). This also makes the byte and string readers consistent with their generic VecM<T> counterpart, which already grows as elements are read.

Known limitations

N/A

Close #623

@leighmcculloch
leighmcculloch marked this pull request as ready for review November 27, 2026 07:21
@leighmcculloch
leighmcculloch requested a review from a team November 27, 2026 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BytesM, StringM and VecM<u8> allocate the full length prefix before reading the body under Limits::none()

1 participant