Skip to content

fix: assorted#122

Merged
mempirate merged 12 commits intomainfrom
jonas/fix/assorted-2
Nov 27, 2025
Merged

fix: assorted#122
mempirate merged 12 commits intomainfrom
jonas/fix/assorted-2

Conversation

@mempirate
Copy link
Contributor

@mempirate mempirate commented Nov 25, 2025

Mainly ensures the ReqDriver plays more nicely with Framed. We ignore Framed's internal backpressure mechanism (respected when poll_ready is called) and flush manually.

I realized with this PR that we should get rid of Framed at least for writing messages, as it needlessly copies and buffers bytes that could be written directly to an underlying Io object.

@mempirate mempirate marked this pull request as draft November 25, 2025 16:28
@mempirate mempirate marked this pull request as ready for review November 26, 2025 15:53
@mempirate mempirate requested a review from thedevbirb November 26, 2025 15:54
Comment on lines +31 to 40
/// An object that represents a connected peer and associated state.
///
/// # Usage of Framed
/// [`Framed`] is used for encoding and decoding messages ("frames").
/// Usually, [`Framed`] has its own internal buffering mechanism, that's respected
/// when calling `poll_ready` and configured by [`Framed::set_backpressure_boundary`].
///
/// However, we don't use `poll_ready` here, and instead we flush whenever the write buffer contains
/// data (i.e., every time we write a message to it).
pub(crate) struct PeerState<T: AsyncRead + AsyncWrite, A: Address> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Reading this makes me think: do we really need Framed then? Can't we extract the encoding/decoding out of if and write to/read from the underlying transport?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it's a just a matter of rephrasing the documentation, highlighting why we still think it's useful to have. Perhaps the polling functionality over incoming messages on the transport.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check the PR description above - for reading, it's nice to have, but for writing, we don't need it and it in fact results in an additional message copy (the raw message into the Framed buffer).

However, for high throughput profiles, it may actually make sense to reintroduce batched flushes to reduce syscall overhead. So we'll have to see

@mempirate mempirate merged commit 0e87e65 into main Nov 27, 2025
11 checks passed
@mempirate mempirate deleted the jonas/fix/assorted-2 branch November 27, 2025 12:25
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

Comments