Intelligent anti-bufferboat in picomux #52
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Flow control in picomux is based on a basic per-stream sliding window approach:
INIT_WINDOW
MORE
framesGenerally, we want the window to be as small as possible, while still being big enough to fill the pipe. Oversized windows have two problems with "bufferbloat":
Currently, there are heuristics for avoiding 1. (which is important because of how central picomux-over-picomux is to the whole Geph bridge system), but none for 2 other than attempting to use low-level socket options to limit TCP buffering on Linux. These options kinda work, but network-level TCP middleboxes can easily cause unfixable bufferbloat. Ensuring that every combination of underlying transport is bloat-free is also basically impossible.
This PR instead attempts to very generously estimate the BDP and limit the window to that:
This prevents causing more than 500ms or so of bufferbloat in the underlying transport, and on top of that the way bandwidth is estimated also prevents bufferbloat within the picomux stream by slow readers, so it kills two birds with one stone.
(We don't try to use the measured ping, since that can cause a bloat -> measured ping increases -> more bloat is allowed cycle)