Skip to content

Conversation

@clabby
Copy link
Collaborator

@clabby clabby commented Dec 18, 2025

Overview

Alters the core networking APIs to use Buf / BufMut rather than StableBuf. This unlocks passing non-contiguous buffers + vectorized read/write operations.

closes #784

@clabby clabby self-assigned this Dec 18, 2025
@clabby clabby added the breaking-api This PR modifies the public interface of a function. label Dec 18, 2025
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 18, 2025

Deploying monorepo with  Cloudflare Pages  Cloudflare Pages

Latest commit: 429c414
Status: ✅  Deploy successful!
Preview URL: https://0f4be186.monorepo-eu0.pages.dev
Branch Preview URL: https://cl-vectored-network.monorepo-eu0.pages.dev

View logs

@clabby clabby force-pushed the cl/vectored-network branch from 3ceff94 to c376e34 Compare December 18, 2025 19:51
@clabby clabby changed the title [runtime] Buffered networking APIs [runtime/p2p] Buffered networking APIs Dec 18, 2025
@clabby clabby marked this pull request as ready for review December 18, 2025 20:23
@clabby clabby force-pushed the cl/vectored-network branch 3 times, most recently from 3106904 to d29b10d Compare December 19, 2025 18:47
@clabby clabby force-pushed the cl/vectored-network branch 3 times, most recently from 233a1d2 to 8f6dfef Compare December 22, 2025 15:19
@clabby clabby force-pushed the cl/vectored-network branch from 8f6dfef to b7faedd Compare December 22, 2025 15:28
@clabby clabby changed the title [runtime/p2p] Buffered networking APIs [runtime/p2p] Use Buf / BufMut in networking APIs Dec 22, 2025
@clabby clabby force-pushed the cl/vectored-network branch from b7faedd to 957c3ae Compare December 22, 2025 15:37
andresilva
andresilva previously approved these changes Dec 22, 2025
buf.put_slice(&message);
self.inner.send(buf.freeze(), priority).await
self.inner
.send(subchannel.encode().chain(message), priority)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

len.write(&mut prefixed_buf);
prefixed_buf.extend_from_slice(buf);
sink.send(prefixed_buf).await.map_err(Error::SendFailed)
let data = len.encode().freeze().chain(buf);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

(this one will actually get vectored)

@clabby clabby force-pushed the cl/vectored-network branch 2 times, most recently from de1b2d6 to ba0fb8a Compare December 26, 2025 16:06
@clabby clabby added this to Tracker Jan 5, 2026
@clabby clabby moved this to Ready for Review in Tracker Jan 5, 2026
&mut self,
buf: impl Into<StableBuf> + Send,
) -> impl Future<Output = Result<StableBuf, Error>> + Send;
fn recv(&mut self, buf: impl BufMut + Send) -> impl Future<Output = Result<(), Error>> + Send;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a trait alias for BufMut + Send

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so; It's only used 7 times in the whole codebase & is a bit more clear to have inline.

@clabby clabby force-pushed the cl/vectored-network branch from ba0fb8a to e7f0fd7 Compare January 5, 2026 20:58
@clabby clabby force-pushed the cl/vectored-network branch 3 times, most recently from 410dcfe to 14c4508 Compare January 5, 2026 22:07
Copy link
Contributor

@patrick-ogrady patrick-ogrady left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left my changes here: #2706

@clabby clabby requested a review from patrick-ogrady January 6, 2026 03:26
Copy link
Collaborator

@andresilva andresilva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could have:

  • Encode::encode_mut() -> BytesMut
  • Encode::encode() -> Bytes { self.encode_mut().freeze() }

This would remove all of the encode().freeze() noise and make sure we actually freeze as much as we can (I think we are missing a lot of places?). We probably wouldn't use encode_mut() anywhere right now (but not sure about this, should be trivial anyway).

@clabby clabby force-pushed the cl/vectored-network branch from 2b71082 to 8af9de0 Compare January 6, 2026 15:42
@clabby clabby force-pushed the cl/vectored-network branch from 8af9de0 to 429c414 Compare January 6, 2026 15:43
@patrick-ogrady patrick-ogrady merged commit fcb1f0f into main Jan 6, 2026
127 checks passed
@patrick-ogrady patrick-ogrady deleted the cl/vectored-network branch January 6, 2026 17:14
@github-project-automation github-project-automation bot moved this from Ready for Review to Done in Tracker Jan 6, 2026
@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

❌ Patch coverage is 99.72376% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.81%. Comparing base (ff8fefb) to head (429c414).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...rc/authenticated/discovery/actors/tracker/actor.rs 0.00% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main    #2558      +/-   ##
==========================================
- Coverage   92.82%   92.81%   -0.01%     
==========================================
  Files         361      361              
  Lines      106797   106800       +3     
==========================================
- Hits        99134    99129       -5     
- Misses       7663     7671       +8     
Files with missing lines Coverage Δ
codec/src/codec.rs 100.00% <100.00%> (ø)
codec/src/types/hash_map.rs 100.00% <100.00%> (ø)
codec/src/types/hash_set.rs 100.00% <100.00%> (ø)
collector/src/p2p/mocks/sender.rs 100.00% <100.00%> (ø)
collector/src/p2p/mod.rs 98.97% <100.00%> (ø)
consensus/src/aggregation/types.rs 97.40% <100.00%> (ø)
consensus/src/marshal/actor.rs 92.86% <100.00%> (ø)
consensus/src/ordered_broadcast/engine.rs 85.95% <100.00%> (ø)
consensus/src/simplex/actors/batcher/mod.rs 97.45% <100.00%> (-0.01%) ⬇️
consensus/src/simplex/actors/resolver/actor.rs 79.74% <100.00%> (ø)
... and 49 more

... and 1 file 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 ff8fefb...429c414. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-api This PR modifies the public interface of a function.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[runtime/stream] Support the use of OwnedWriteHalf::write_vectored

4 participants