refactor(transport): extract shared stream state handling logic in loopyWriter.processData()#9125
refactor(transport): extract shared stream state handling logic in loopyWriter.processData()#9125Exgene wants to merge 2 commits into
loopyWriter.processData()#9125Conversation
|
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9125 +/- ##
==========================================
- Coverage 83.21% 83.13% -0.08%
==========================================
Files 413 413
Lines 33482 33479 -3
==========================================
- Hits 27863 27834 -29
- Misses 4212 4224 +12
- Partials 1407 1421 +14
🚀 New features to boost your workflow:
|
|
how do i add labels? i can't really add it from my side on the sidebar, and it wasn't present in the contributing guidelines either. |
loopyWriter.processData()
|
@arjan-bal : Could you please take a look at this one? Thanks. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the processData method in internal/transport/controlbuf.go by extracting duplicated stream update logic into a new helper method called updateStreamAfterWrite. This helper method now centralizes the logic for updating stream states, handling trailers, and re-enqueuing active streams after a write operation. I have no feedback to provide as there were no review comments to evaluate.
arjan-bal
left a comment
There was a problem hiding this comment.
Some minor comments, otherwise LGTM. Please address them before I add a second reviewer.
| if err := l.updateStreamAfterWrite(str); err != nil { | ||
| return false, err | ||
| } |
There was a problem hiding this comment.
nit: Can be simplified as return false, l.updateStreamAfterWrite(str). Same for the updateStreamAfterWrite below.
| } | ||
| } else if int(l.oiws)-str.bytesOutStanding <= 0 { // Ran out of stream quota. | ||
| str.state = waitingOnStreamQuota | ||
| } else { // Otherwise add it back to the list of active streams. |
There was a problem hiding this comment.
Can you please leave the comment here?
|
happy to add them! |
There was a problem hiding this comment.
Is suspect we can remove this special handing of empty data frames if we just modify the following check below to not return early:
grpc-go/internal/transport/controlbuf.go
Lines 983 to 986 in 6093108
It should be something similar to:
isEmpty := len(dataItem.h) == 0 && reader.Remaining() == 0
if strQuota <= 0 && !isEmpty {
// return early
}Can you check if this is possible?
To clarify, I'll add the second reviewer after you've addressed the pending comments. |
|
@arjan-bal I have refactored it accordingly, I think there is this one case where the frame is empty and the value of I also refactored else if maxSize > strQuota {
maxSize = strQuota
}with simpler maxSize = min(maxSize, int(l.sendQuota)) And finally in the empty frame case should |
|
Also not sure why that test case is failing. |
Fixes: #9117
Refactors the duplicated post write stream state handling in
loopyWriter.processData()present ininternal/transport/controlbuf.gointo a shared helperl.updateStreamAfterWrite(). Both empty and non empty DATA frame paths now share the same stream state handling logic.This change also adds the stream quota check
(int(l.oiws) - str.bytesOutStanding)to the empty frame path. This is safe because empty DATA frames send 0 bytes, sobytesOutStandingdoesn't change.RELEASE NOTES: n/a