Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Conversation

@eskimor
Copy link
Member

@eskimor eskimor commented Mar 19, 2021

No description provided.

@eskimor eskimor added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. labels Mar 19, 2021
@bkchr bkchr requested review from romanb and tomaka March 19, 2021 20:14
if let State::Open { notifications_sink_rx, out_substream: out_substream @ Some(_), .. }
= &mut self.protocols[protocol_index].state
{
let mut flush_needed = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is local, if a flush is needed but poll_flush returns Poll::Pending, it looks like the handler may not call poll_flush() again when it is next polled? I would think that not wanting to track such state is why the current code always calls poll_flush() for each open substream in the removed block above. Please correct me if I'm mistaken.

Copy link
Member

Choose a reason for hiding this comment

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

Good point!

The problem that we have encountered is that flush wasn't called at all, we assume that this was probably due to other substreams being more busy or whatever.

As I'm thinking more about this, the current implementation isn't really robust. It could happen that a stream with a lower procotol_index could starve other streams. There is already this events_queue. We should insert every event in there and to ensure that we poll all incoming and outgoing streams. At the end of this loop we should check if there is something in the events_queue and return that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch @romanb ! Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

As I'm thinking more about this, the current implementation isn't really robust. It could happen that a stream with a lower procotol_index could starve other streams. There is already this events_queue. We should insert every event in there and to ensure that we poll all incoming and outgoing streams. At the end of this loop we should check if there is something in the events_queue and return that.

Problem: We lose back pressure. events_queue could grow indefinitely in that case.

Copy link
Member

Choose a reason for hiding this comment

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

Why do we loose the back pressure? The event queue was checked before we polled for new events?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I wanted to avoid checking before and after and if we only check afterwards, we got that issue. If we only checked first, we would return Pending although we are actually Ready. Either way @tomaka seems skeptic that we solve anything here.

@eskimor
Copy link
Member Author

eskimor commented Mar 21, 2021

Hopefully better fix here.

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

Labels

A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants