Skip to content

Conversation

@riptl
Copy link

@riptl riptl commented Nov 19, 2025

Improves unpack performance for vectors by allowing the compiler to vectorize flatbuffers::Vector to std::vec::Vec conversions, using the unstable trusted_len feature.

Internally, enables an optimization in src/alloc/vec/spec_extend.rs: Previously, unpacking a flatbuffers::Vector called SpecExtend::extend_desugared fallback, which inhibits vectorization (due to a branch before every element move). Declaring TrustedLen allows SpecExtend::extend_trusted, which LLVM can often vectorize into a memcpy.

For [ubyte] vectors in particular, this turns a rather expensive loop of 'mov BYTE PTR [rax+r13*1], bpl' into a call memcpy.

Improves unpack performance for vectors by allowing the compiler
to vectorize flatbuffers::Vector to std::vec::Vec conversions,
using the unstable trusted_len feature.

Internally, enables an optimization in src/alloc/vec/spec_extend.rs:
Previously, unpacking a flatbuffers::Vector called
SpecExtend::extend_desugared fallback, which inhibits vectorization
(due to a branch before every element move).  Declaring TrustedLen
allows SpecExtend::extend_trusted, which LLVM can often vectorize
into a memcpy.

For [ubyte] vectors in particular, this turns a rather expensive
loop of 'mov BYTE PTR [rax+r13*1], bpl' into a `call memcpy`.
@google-cla
Copy link

google-cla bot commented Nov 19, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions bot added the rust label Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant