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

Add page abount flow control #83

Merged
merged 1 commit into from
Oct 16, 2023
Merged

Conversation

FelonEkonom
Copy link
Member

@FelonEkonom FelonEkonom requested a review from mat-hek September 25, 2023 12:52
Copy link
Member

@mat-hek mat-hek left a comment

Choose a reason for hiding this comment

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

Let's put it into grammarly too


- output pad with `flow_control: :manual` - the element gets the information, through the `handle_demand` callback, how much data a specific output pad needs. An element having an output pad with `:manual` `flow control` is obligated to satisfy the demand on it.

- input pad with `flow_control: :auto` - since `v1.0.0-rc1` the default `flow control` value. Unlike in manual demands, the element must not directly specify the demand value on the input pad to receive buffers on it. In `:auto` `flow control`, the framework will manage the demand value itself. In the case of Sources and Endpoints, it will make sure that the demand on the input pad is positive as long as the number of buffers waiting for processing in the mailbox is not too large. In the case of filters, Membrane will take care of a positive demand on under one additional condition - the demand value on all output pads with `flow_control: :auto` of this element must also be positive.
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't mention the new defaults until we have 1.0

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- input pad with `flow_control: :auto` - since `v1.0.0-rc1` the default `flow control` value. Unlike in manual demands, the element must not directly specify the demand value on the input pad to receive buffers on it. In `:auto` `flow control`, the framework will manage the demand value itself. In the case of Sources and Endpoints, it will make sure that the demand on the input pad is positive as long as the number of buffers waiting for processing in the mailbox is not too large. In the case of filters, Membrane will take care of a positive demand on under one additional condition - the demand value on all output pads with `flow_control: :auto` of this element must also be positive.
- input pad with `flow_control: :auto` - since `v1.0.0-rc1` the default `flow control` value. Unlike in manual demands, the element doesn't have to directly specify the demand value on the input pad to receive buffers on it. In `:auto` `flow control`, the framework will manage the demand value itself. In the case of Sources and Endpoints, it will make sure that the demand on the input pad is positive as long as the number of buffers waiting for processing in the mailbox is not too large. In the case of filters, Membrane will take care of a positive demand on under one additional condition - the demand value on all output pads with `flow_control: :auto` of this element must also be positive.


- output pad with `flow_control: :push` - the element decides for itself when to send how many buffers via a given pad.

- input pad with `flow_control: :manual` - the element directly, using the `demand` action, determines how much data it wants to receive from this pad. Membrane guarantees that more data will never come to the input pad than was demanded..
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- input pad with `flow_control: :manual` - the element directly, using the `demand` action, determines how much data it wants to receive from this pad. Membrane guarantees that more data will never come to the input pad than was demanded..
- input pad with `flow_control: :manual` - the element directly, using the `demand` action, requests how much data it wants to receive from this pad. Membrane guarantees that more data will never come to the input pad than was demanded.


- input pad with `flow_control: :auto` - since `v1.0.0-rc1` the default `flow control` value. Unlike in manual demands, the element must not directly specify the demand value on the input pad to receive buffers on it. In `:auto` `flow control`, the framework will manage the demand value itself. In the case of Sources and Endpoints, it will make sure that the demand on the input pad is positive as long as the number of buffers waiting for processing in the mailbox is not too large. In the case of filters, Membrane will take care of a positive demand on under one additional condition - the demand value on all output pads with `flow_control: :auto` of this element must also be positive.

- output pad with `flow_control: :output` - an auto output pad does not require from the element to implement the `handle_demand` callback. The demand value on this pad only matters when the framework itself calculates the value of the auto demand on the input pads.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- output pad with `flow_control: :output` - an auto output pad does not require from the element to implement the `handle_demand` callback. The demand value on this pad only matters when the framework itself calculates the value of the auto demand on the input pads.
- output pad with `flow_control: :auto` - an auto output pad does not require from the element to implement the `handle_demand` callback. The demand value on this pad only matters when the framework itself calculates the value of the auto demand on the input pads.


- input pad with `flow_control: :manual` - the element directly, using the `demand` action, determines how much data it wants to receive from this pad. Membrane guarantees that more data will never come to the input pad than was demanded..

- output pad with `flow_control: :manual` - the element gets the information, through the `handle_demand` callback, how much data a specific output pad needs. An element having an output pad with `:manual` `flow control` is obligated to satisfy the demand on it.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- output pad with `flow_control: :manual` - the element gets the information, through the `handle_demand` callback, how much data a specific output pad needs. An element having an output pad with `:manual` `flow control` is obligated to satisfy the demand on it.
- output pad with `flow_control: :manual` - the element gets the information, through the `handle_demand` callback, how much data a specific output pad needs. An element having an output pad with `flow control: :manual` is obligated to satisfy the demand on it.

Copy link
Member

Choose a reason for hiding this comment

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

Also, let's add an example of when manual demands are needed


When defining a pad od an element, you can pass one of 3 values in the `flow_control` field: `auto`, `push`, or `manual`. They determine how the backpressure mechanism works on the pad they relate to.

- input pad with `flow_control: :push` - an element with such a pad must always be ready to receive a new buffer on that pad. The output pad linked with such a input pad must also have `flow control` set to `:push`.
Copy link
Member

Choose a reason for hiding this comment

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

Let's start with capital letters


When defining a pad od an element, you can pass one of 3 values in the `flow_control` field: `auto`, `push`, or `manual`. They determine how the backpressure mechanism works on the pad they relate to.

- input pad with `flow_control: :push` - an element with such a pad must always be ready to receive a new buffer on that pad. The output pad linked with such a input pad must also have `flow control` set to `:push`.
Copy link
Member

Choose a reason for hiding this comment

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

I'd mention that it's usually not advised to use push input, as it's prone to overflow

@FelonEkonom FelonEkonom force-pushed the get-started-with-flow-control branch 2 times, most recently from baaa645 to 46f829d Compare September 26, 2023 09:52
- `manual`, these buffers will wait in line until the element raises the demand on its input by returning the `demand` action.
- `auto`, these buffers will be processed, and the demand value on the input pad will drop below zero.

In both of the above cases, when much more data is sent than was demanded on the input pad, a `toilet overflow` error will be thrown. It means that the element with the push output pad sends more data than the rest of the pipeline can process. We can control the limit value, above which the `toilet overflow` error will be thrown, using the `toilet_capacity` option passed to the `via_in/3` function when creating the spec, e.g.
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 only true if the effective flow control is pull

Base automatically changed from guide to main October 4, 2023 12:13
@FelonEkonom FelonEkonom requested a review from mat-hek October 12, 2023 13:12
@FelonEkonom FelonEkonom force-pushed the get-started-with-flow-control branch from 6337ae7 to 35d9bbe Compare October 16, 2023 11:56
@FelonEkonom FelonEkonom force-pushed the get-started-with-flow-control branch from 35d9bbe to d5f5dfc Compare October 16, 2023 11:58
@FelonEkonom FelonEkonom merged commit b3d3018 into main Oct 16, 2023
@FelonEkonom FelonEkonom deleted the get-started-with-flow-control branch October 16, 2023 11:58
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