Skip to content

Comments

feat(bytesbuf): reduce unnecessary reference count jiggling#283

Merged
sandersaares merged 2 commits intomainfrom
sandersaares/issue-279-reduce-refcount-jiggling
Feb 25, 2026
Merged

feat(bytesbuf): reduce unnecessary reference count jiggling#283
sandersaares merged 2 commits intomainfrom
sandersaares/issue-279-reduce-refcount-jiggling

Conversation

@sandersaares
Copy link
Member

@sandersaares sandersaares commented Feb 23, 2026

Summary

Eliminate unnecessary atomic reference count operations in BytesView by avoiding clones in PartialEq and BytesViewSlices.

Changes

  • 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.
  • Benchmarks: Add early-exit inequality and slices iteration benchmarks.

Benchmark results

  • slices_iterate: ~32% faster
  • ne_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

@codecov
Copy link

codecov bot commented Feb 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.0%. Comparing base (56d48cf) to head (e387866).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sandersaares sandersaares force-pushed the sandersaares/issue-279-reduce-refcount-jiggling branch 2 times, most recently from 36d13f5 to f63c8c9 Compare February 23, 2026 08:54
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
@sandersaares sandersaares force-pushed the sandersaares/issue-279-reduce-refcount-jiggling branch from f63c8c9 to 522d0ef Compare February 23, 2026 09:27
@sandersaares sandersaares marked this pull request as ready for review February 23, 2026 09:45
@sandersaares sandersaares enabled auto-merge (squash) February 25, 2026 13:45
@sandersaares sandersaares merged commit 864b0f6 into main Feb 25, 2026
48 checks passed
@sandersaares sandersaares deleted the sandersaares/issue-279-reduce-refcount-jiggling branch February 25, 2026 16:41
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.

feat(bytesbuf): Reduce unnecessary reference count jiggling

3 participants