Repository navigation
http2: remove unnecessary negative_capacity_ - #19057
Conversation
|
The use of negative_capacity_ is hard to understand. In my opinion, when the stream destroyed, if the capacity caculated by remaining streams (remaining_streams_) > the capacity caculated by concurrency (concurrent_stream_limit_ - numActiveStreams() - 1), we could increase the ConnectingAndConnectedStreamCapacity and we don't need negative_capacity_ which just complicates the logic. Because the type of concurrent_stream_limit_ and numActiveStreams() is uint32_t, when concurrent_stream_limit_ < numActiveStreams() + 1, then (concurrent_stream_limit_ - numActiveStreams() - 1) could result overflow. Obviously, in this case, we should increase ConnectingAndConnectedStreamCapacity. So compare concurrent_stream_limit_ and @alyssawilk WDYT :) |
|
/retest |
|
Retrying Azure Pipelines: |
|
/retest |
|
Retrying Azure Pipelines: |
|
/assign @RyanTheOptimist |
RyanTheOptimist
left a comment
There was a problem hiding this comment.
Just a couple of minor cosmetic comments.
| if (trackStreamCapacity() && (client.remaining_streams_ > client.concurrent_stream_limit_ - | ||
| client.numActiveStreams() - 1 || | ||
| had_negative_capacity)) { | ||
| // The capacity caculated by concurrency could be negative, in this case, efficient client |
There was a problem hiding this comment.
nit: should this be "effective" instead of "efficient"?
| cacert | ||
| cacheable | ||
| cacheability | ||
| caculated |
There was a problem hiding this comment.
I think this is a typo and we probably don't want to include it here, do we?
| nanos | ||
| natively | ||
| ndk | ||
| negative |
There was a problem hiding this comment.
Wow, I'm surprised that "negative" is not already known!
|
@RyanTheOptimist updated. |
|
/assign @alyssawilk |
|
@alyssawilk PTAL at this one :) |
There was a problem hiding this comment.
While I like the simplification of removing the negative capacity member variable, I think this if statement was already hard to read and is now really hard to read :-)
Let's break it up. Something like
// We don't update the capacity for HTTP/3
if (trackStreamCapacity()) {
// If the effective client capacity was limited by max total streams...
bool limited_by_concurrency = ...
// The capacity calculated by concurrency could be negative [maybe explicitly call out SETTINGS frame
bool has_newly_available_capacity = ...
if (limited_by_concurrency && has_newly_available_capacity) {
state.incr....
}
|
/retest |
|
Retrying Azure Pipelines: |
|
/retest |
|
Retrying Azure Pipelines: |
Signed-off-by: YaoZengzeng <[email protected]>
Signed-off-by: YaoZengzeng <[email protected]>
Signed-off-by: YaoZengzeng <[email protected]>
Signed-off-by: YaoZengzeng <[email protected]>
This reverts commit 705684d. Signed-off-by: YaoZengzeng <[email protected]>
Signed-off-by: YaoZengzeng <[email protected]>
5bb59a0 to
7d65dde
Compare
| client.numActiveStreams() - 1 || | ||
| had_negative_capacity)) { | ||
| state_.incrConnectingAndConnectedStreamCapacity(1); | ||
| // We don't update the capacity for HTTP/3 as the stream count should only. |
There was a problem hiding this comment.
I think this comment got truncated?
| // If the effective client capacity was limited by concurrency, increase connecting capacity. | ||
| bool limited_by_concurrency = | ||
| client.remaining_streams_ > client.concurrent_stream_limit_ - client.numActiveStreams() - 1; | ||
| // The capacity calculated by concurrency could be negative (maybe explicitly call out SETTINGS |
There was a problem hiding this comment.
"maybe explicitly call out SETTINGS frame"
Oops, I didn't mean this one to be a literal suggestion :-P
// The capacity calculated by concurrency could be negative if a SETTINGS frame lowered the number of
// allowed streams. In this case, effective client capacity was still limited by concurrency, compare
// client.concurrent_stream_limit_ and client.numActiveStreams() directly to avoid overflow.
Signed-off-by: YaoZengzeng <[email protected]>
|
@alyssawilk thanks for your review, it's always need a lot of time to sync because of time difference 😄 |
|
and with US holidays! Thanks again for your patience - it's wonderful seeing this area of code cleaned up! |
Commit Message: remove negative_capacity_ to make the code easier to understand
Additional Description: fixes part I of #18880
Risk Level: high
Testing: unit
Docs Changes: n/a