Skip to content

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

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

Specialize BytesMut::extend<u8> when its Vec-backed#829
AdamGS wants to merge 1 commit 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 400 MB/s to 9846MB/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
Signed-off-by: Adam Gutglick <adam@spiraldb.com>
@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

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