Repository navigation
Improve ZeroVec sum performance - #8732
Merged
Merged
Conversation
Manishearth
approved these changes
Nov 18, 2026
sffc
approved these changes
Nov 19, 2026
sffc
left a comment
Member
There was a problem hiding this comment.
I wish Rust had a better way to delegate impls. Adding one-off overrides to fns that are motivated by benchmarks seems fine.
Member
|
Thank you for the contribution! |
Manishearth
approved these changes
Nov 19, 2026
Member
I mean the default is delegation, this is just delegating in a way that is not the best. |
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.
Fixes #6562.
Forward
ZeroSliceIter::foldthrough the underlying slice iterator. With Rust 1.98.0 on x86_64, the existingzerovec_serde/sum/stress/zerovecbenchmark now uses a vectorized reduction; the original binary emitted a scalar loop.Using the checked-in benchmark and bench profile, two runs per binary in A/B/B/A order gave these Criterion slope estimates:
sum/stress/zerovecsum/stress/vec(control)The Vec control's loop instructions are byte-identical, but its placement and timings changed. These measurements are specific to this benchmark and setup.
Tests cover empty and forward/reverse folds, plus folding after taking elements from both ends.
cargo test -p zerovec --all-featuresandcargo clippy -p zerovec --all-features --all-targets -- -D warningspass.Changelog
zerovec: Improve summation performance forZeroSliceIter.