You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following is only theoretical as I've not checked if it happens or not. But looking at the code and running some simplified computations, I have the impression that the almost_full function may tends to true once the received offset is sufficiently large compared to the initial max_data.
Here, max_data_next is increased by the len of the emited packets.
I believe max_data_next increases constantly but max_data - (total)_len is heuristically bounded by the regular increase of max_data. Supposing that this bound is the initial value of max_data, then once max_data_next > 2*initial_max_data the stream tends to be always declared almost full.
If this is indeed true, the practical implication would be that MAX_STREAM_DATA frames would be send at a high frequency once this threshold is passed. Is it the behavior intended?
pub fn almost_full(&self) -> bool {
// Send MAX_STREAM_DATA when the new limit is at least double the
// amount of data that can be received before blocking.
if self.fin_off.is_none() &&
self.max_data_next != self.max_data &&
self.max_data_next / 2 > self.max_data - self.len {
println!("{:?} ALMOST FULL", self);
true
} else {
println!("{:?} OK", self);
false
}
}
I've shortened the trace but it's easy to see the pattern where the stream is declared almost full more and more frequently until it is always declared almost full.
I believe a fix could be to store the amount of available control flow credit (i.e. max_data_next - self.len) when sending a MAX_STREAM_DATA frame and use that value divided by two to decide if the stream is almost full instead of max_data_next/2. i.e. declare a stream almost full once half of the control flow credits available since last MAX_STREAM_DATA frames has been consumed.
Fixed by e79ea93, released in 0.11.0, which replaced this heuristic with window-based flow control. A stream now sends MAX_STREAM_DATA only when its available window falls below half of the window.
Activity
[-]almost_full tends to true [theoretically][/-][+]almost_full tends to true[/+]Sparika commentedon Jun 24, 2021
I can confirm I am observing the behavior I've described in practice. The setup is a server sending a large amount of data to a client.
The client is configured with the following
And here what I'm observing:
I've shortened the trace but it's easy to see the pattern where the stream is declared almost full more and more frequently until it is always declared almost full.
I believe a fix could be to store the amount of available control flow credit (i.e.
max_data_next - self.len) when sending aMAX_STREAM_DATAframe and use that value divided by two to decide if the stream is almost full instead ofmax_data_next/2. i.e. declare a stream almost full once half of the control flow credits available since lastMAX_STREAM_DATAframes has been consumed.ghedo commentedon Jun 29, 2021
Your analysis looks correct, in fact this is a known issue, just haven't gotten to fixing it yet.
Would you like to provide a PR with a possible fix? Otherwise might take us a bit longer to fix.
Sparika commentedon Jun 30, 2021
Yes, I think that is something I can look into.
Any requirements regarding PR and contributions I should know about ?
fly869 commentedon Dec 7, 2022
Is the problem finally solved? @Sparika @ghedo
ghedo commentedon Nov 25, 2026
Fixed by e79ea93, released in 0.11.0, which replaced this heuristic with window-based flow control. A stream now sends MAX_STREAM_DATA only when its available window falls below half of the window.