Skip to content

chore: use Byte instead of Vec<u8> in some channels#6901

Merged
LesnyRumcajs merged 1 commit intomainfrom
bytes-in-channels
Apr 14, 2026
Merged

chore: use Byte instead of Vec<u8> in some channels#6901
LesnyRumcajs merged 1 commit intomainfrom
bytes-in-channels

Conversation

@LesnyRumcajs
Copy link
Copy Markdown
Member

@LesnyRumcajs LesnyRumcajs commented Apr 14, 2026

Summary of changes

This saves some allocation cloning

When a value is sent, all Receiver handles are notified and will receive the value. The value is stored once inside the channel and cloned on demand for each receiver. Once all receivers have received a clone of the value, the value is released from the channel.

See https://docs.rs/tokio/latest/tokio/sync/broadcast/index.html

Bytes's clone is a shallow clone so it would just increment a counter

Reference issue to close (if applicable)

Closes

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

Outside contributions

  • I have read and agree to the CONTRIBUTING document.
  • I have read and agree to the AI Policy document. I understand that failure to comply with the guidelines will lead to rejection of the pull request.

Summary by CodeRabbit

  • Refactor
    • Updated internal data type representations in write operations handling across storage components for improved efficiency and consistency.

@LesnyRumcajs LesnyRumcajs requested a review from a team as a code owner April 14, 2026 13:30
@LesnyRumcajs LesnyRumcajs requested review from hanabi1224 and sudo-shashank and removed request for a team April 14, 2026 13:30
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1973c893-886a-41e0-a80c-365958741e43

📥 Commits

Reviewing files that changed from the base of the PR and between 7d1062a and 475b3e9.

📒 Files selected for processing (5)
  • src/db/car/many.rs
  • src/db/gc/snapshot.rs
  • src/db/mod.rs
  • src/db/parity_db.rs
  • src/db/parity_db/gc.rs

Walkthrough

The changes update the broadcast payload type for blockstore write operations subscriptions from Vec<(Cid, Vec<u8>)> to Vec<(Cid, bytes::Bytes)> across the trait definition and all implementations.

Changes

Cohort / File(s) Summary
Trait and Wrapper Implementations
src/db/mod.rs, src/db/car/many.rs, src/db/parity_db/gc.rs
Updated BlockstoreWriteOpsSubscribable::subscribe_write_ops return type from Receiver<Vec<(Cid, Vec<u8>)>> to Receiver<Vec<(Cid, bytes::Bytes)>> across trait definition and delegating implementations.
ParityDb Implementation
src/db/parity_db.rs
Updated subscribe_write_ops return type and modified put_keyed and put_many_keyed paths to construct bytes::Bytes payloads using Bytes::copy_from_slice for subscriber notifications; tests updated to assert new payload types.
Snapshot Garbage Collector
src/db/gc/snapshot.rs
Changed SnapshotGarbageCollector::memory_db field type from RwLock<Option<HashMap<Cid, Vec<u8>>>> to RwLock<Option<HashMap<Cid, bytes::Bytes>>> for export staging store.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing Vec with Bytes in broadcast channels across multiple files to reduce allocation overhead.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bytes-in-channels
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch bytes-in-channels

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 14, 2026

Codecov Report

❌ Patch coverage is 62.50000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.96%. Comparing base (c934f0f) to head (475b3e9).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/db/car/many.rs 0.00% 1 Missing ⚠️
src/db/parity_db.rs 83.33% 1 Missing ⚠️
src/db/parity_db/gc.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/db/gc/snapshot.rs 0.00% <ø> (ø)
src/db/mod.rs 37.25% <ø> (ø)
src/db/car/many.rs 62.08% <0.00%> (ø)
src/db/parity_db.rs 69.00% <83.33%> (-0.25%) ⬇️
src/db/parity_db/gc.rs 33.05% <0.00%> (ø)

... and 4 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c934f0f...475b3e9. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@LesnyRumcajs LesnyRumcajs enabled auto-merge April 14, 2026 13:54
@LesnyRumcajs LesnyRumcajs added this pull request to the merge queue Apr 14, 2026
Merged via the queue into main with commit e55a0a3 Apr 14, 2026
45 of 46 checks passed
@LesnyRumcajs LesnyRumcajs deleted the bytes-in-channels branch April 14, 2026 14:27
@coderabbitai coderabbitai Bot mentioned this pull request Apr 14, 2026
6 tasks
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.

2 participants