Replace Vec<u8> with Bytes - #4684
Open
MartinquaXD wants to merge 3 commits into
Open
Conversation
MartinquaXD
force-pushed
the
use-bytes-crate
branch
from
July 30, 2026 09:06
f00f71d to
9217928
Compare
Contributor
Author
|
@claude do your thing |
Contributor
|
Claude finished @MartinquaXD's task in 4m 20s —— View job PR Review: Replace
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A lot of data we have to pass around is currently stored in
Vec<u8>(e.g. calldata, signatures). Cloning those is very expensive because we always need to do a full clone (fresh allocation + copying all the bytes). This can be avoided by usingbytes::Bytes. That's effectively an immutable and reference countedVec<u8>which makes clones just an atomic pointer increment.Changes
replaced
Vec<u8>withbytes::Bytesalmost everywhere. Exceptions are:sqlxdoesn't support that type)BytesHow to test
all tests should still pass
performance impact can be measured by temporarily deploying to prod