Skip to content

Specialize BytesMut::extend<u8> when its Vec-backed - #829

Open
AdamGS wants to merge 2 commits into
tokio-rs:masterfrom
AdamGS:adamg/specialize-extended-vec
Open

AdamGS wants to merge 2 commits into
tokio-rs:masterfrom
AdamGS:adamg/specialize-extended-vec

Conversation

@AdamGS

@AdamGS AdamGS commented Jun 15, 2026 •

Copy link
Copy Markdown

This PR adds a specialized code path to extending BytesMut when its backed by a Vec. There are no external changes, only a private function and type with some tests.

When benchmarking on my laptop (M3 Max MacBook Pro), the change to put_slice_vec_extend is from 480 MB/s to over 9000MB/s. Happy to bench on some Intel hardware if the data is interesting.

@AdamGS AdamGS changed the title Specialize BytesMut::extend when its Vec-backed Specialize BytesMut::extend<u8> when its Vec-backed Jun 15, 2026
@AdamGS
AdamGS force-pushed the adamg/specialize-extended-vec branch from 02decdb to dc47673 Compare June 15, 2026 19:04
@AdamGS

AdamGS commented Jun 15, 2026

Copy link
Copy Markdown
Author

Messed up an unsafe block, now fixed

Signed-off-by: Adam Gutglick <adam@spiraldb.com>
Signed-off-by: Adam Gutglick <adam@spiraldb.com>
@AdamGS
AdamGS force-pushed the adamg/specialize-extended-vec branch from 444fb1b to 8884ead Compare September 16, 2026 11:13
@AdamGS

AdamGS commented Sep 16, 2026

Copy link
Copy Markdown
Author

I've made another pass at this PR to simplify it. Its mush smaller and simpler now while still having the same performance.

This branch has not been deployed

No deployments
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.

1 participant