feat(bytesbuf): reduce unnecessary reference count jiggling#283
Merged
sandersaares merged 2 commits intomainfrom Feb 25, 2026
Merged
feat(bytesbuf): reduce unnecessary reference count jiggling#283sandersaares merged 2 commits intomainfrom
sandersaares merged 2 commits intomainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #283 +/- ##
=======================================
Coverage 100.0% 100.0%
=======================================
Files 141 141
Lines 8640 8664 +24
=======================================
+ Hits 8640 8664 +24 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
36d13f5 to
f63c8c9
Compare
Eliminate unnecessary atomic reference count operations in BytesView by avoiding clones in PartialEq and BytesViewSlices: - PartialEq<BytesView>: iterate over spans_reversed using indices instead of cloning both views (which incremented atomic ref counts for every span). - PartialEq<&[u8]>: same index-based iteration pattern. - BytesViewSlices: store a reference and index instead of a cloned view, removing unsafe transmute calls in the process. Add benchmarks for early-exit inequality and slices iteration. Closes #279
f63c8c9 to
522d0ef
Compare
geeknoid
approved these changes
Feb 23, 2026
martintmk
approved these changes
Feb 25, 2026
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.
Summary
Eliminate unnecessary atomic reference count operations in
BytesViewby avoiding clones inPartialEqandBytesViewSlices.Changes
PartialEq<BytesView>: Iterate overspans_reversedusing indices instead of cloning both views (which incremented atomic ref counts for every span).PartialEq<&[u8]>: Same index-based iteration pattern.BytesViewSlices: Store a reference and index instead of a cloned view, removingunsafetransmute calls in the process.Benchmark results
slices_iterate: ~32% fasterne_view_early_exit: ~7.5% faster (early-exit benefits most since clone overhead is avoided entirely)(Low confidence, noisy - mostly just to sanity check)
Closes #279