Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: don't allow to open more than 256 unacknowledged streams #153

Merged
merged 39 commits into from
Jul 9, 2023

Conversation

thomaseizinger
Copy link
Contributor

Resolves #150.

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

A lot less intrusive than I thought. Neat!

Also thanks for the simple tests testing a difficult scenario.

test-harness/tests/ack_backlog.rs Show resolved Hide resolved
yamux/src/lib.rs Outdated Show resolved Hide resolved
Comment on lines 134 to 137

pub fn is_acknowledged(&self) -> bool {
self.shared().acknowledged
}
Copy link
Member

Choose a reason for hiding this comment

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

Why expose this to the user? For the test above only? If so, can we move the test instead?

Suggested change
pub fn is_acknowledged(&self) -> bool {
self.shared().acknowledged
}
pub(crate) fn is_acknowledged(&self) -> bool {
self.shared().acknowledged
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think in the context of rust-yamux, this is useful information. Yes, it also allows us to keep the test next to all the others.

I am not too worried about this being in the public API because it is encapsulated within libp2p-yamux anyway. A nice benefit is that our tests are written against a more stable interface instead of reaching into internal data structures.

Copy link
Member

Choose a reason for hiding this comment

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

I think in the context of rust-yamux, this is useful information

In what scenario would a user use it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Until the point where the stream is not acknowledged, this is essentially equivalent to asking a QUIC connection whether it is 0RTT. Anything you write to a stream before it is acknowledged might be discarded by the remote.

yamux/src/connection.rs Outdated Show resolved Hide resolved
yamux/src/connection.rs Outdated Show resolved Hide resolved
yamux/src/connection.rs Outdated Show resolved Hide resolved
@thomaseizinger thomaseizinger changed the title Track ACK backlog and acknowledged state of streams feat: don't allow to open more than 256 unacknowledged streams May 23, 2023
Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

We seem to have a misunderstanding. I don't think inbound streams should be accounted in self.ack_backlog() >= MAX_ACK_BACKLOG.

Comment on lines 364 to 367
// technically, the frame hasn't been sent yet on the wire but from the perspective of this data structure, we've queued the frame for sending
if frame.header().flags().contains(ACK) {
self.set_acknowledged();
}
Copy link
Member

Choose a reason for hiding this comment

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

This is confusing to me. Do I understand correctly that this sets an inbound stream to be acknowledged? Why would the local state machine care whether an inbound stream is acknowledged or not?

Copy link
Contributor Author

@thomaseizinger thomaseizinger May 24, 2023

Choose a reason for hiding this comment

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

We can omit this but it means that the flag is only used by outbound streams which IMO is even more confusing.

I guess I could rename it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I remember why I am doing it for both. I needed that for the test around timing, i.e. when a stream gets acknowledged.

Copy link
Member

Choose a reason for hiding this comment

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

That is fine by me. Though could you please document it for future us?

yamux/src/connection.rs Outdated Show resolved Hide resolved
@thomaseizinger thomaseizinger marked this pull request as draft May 24, 2023 09:26
@thomaseizinger
Copy link
Contributor Author

This is still buggy for some reason. I am not sure if it has to do with the recently merged changes and the GC fix. Will put on hold for now.

@mxinden mxinden mentioned this pull request May 25, 2023
@thomaseizinger
Copy link
Contributor Author

I've merged #164 into here and now this PR passes all tests 🥳

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

Changes here look good to me. Only minor comments. Will review once more once #164 is merged. Or were you planning to merge #164 via this pull request?

yamux/src/connection.rs Show resolved Hide resolved
Comment on lines 134 to 137

pub fn is_acknowledged(&self) -> bool {
self.shared().acknowledged
}
Copy link
Member

Choose a reason for hiding this comment

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

I think in the context of rust-yamux, this is useful information

In what scenario would a user use it?

Comment on lines 364 to 367
// technically, the frame hasn't been sent yet on the wire but from the perspective of this data structure, we've queued the frame for sending
if frame.header().flags().contains(ACK) {
self.set_acknowledged();
}
Copy link
Member

Choose a reason for hiding this comment

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

That is fine by me. Though could you please document it for future us?

yamux/src/connection/stream.rs Outdated Show resolved Hide resolved
@thomaseizinger thomaseizinger marked this pull request as ready for review July 3, 2023 14:40
yamux/src/connection.rs Show resolved Hide resolved
@thomaseizinger thomaseizinger merged commit e7c17ff into libp2p:master Jul 9, 2023
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.

Track the accept backlog and add an upper limit
2 participants