Specify the flow control behavior in BinderChannel protocol#258
Specify the flow control behavior in BinderChannel protocol#258sifmelcara merged 8 commits intogrpc:masterfrom
Conversation
L73-java-binderchannel/wireformat.md
Outdated
|
|
||
| ## Flow Control | ||
|
|
||
| BinderTransport now supports flow control, aiming to keep use of the process transaction buffer to at most 128k. Each transaction we send adds to an internal count of unacknowledged outbound data. If that exceeds 128k, we’ll stop sending transactions until we receive an acknowledgement message from the transport peer. Each transport sends an acknowledgement for each 16k received, which should avoid blocking the transport most of the time. |
There was a problem hiding this comment.
Probably worth to mention that we want to do this because Android binder implementation has an internal buffer with fixed size?
|
if i understand correctly amendments to accepted proposal should not include number in title and commit message |
L73-java-binderchannel/wireformat.md
Outdated
| * From either transport to its peer's binder. Reports reception of | ||
| transaction data for flow control. | ||
| transaction data for flow control. The "num bytes" field should contain | ||
| the sum of "data size" of the parcels received until now. |
There was a problem hiding this comment.
Worth adding a footnote link to Parcel.dataSize()?
https://developer.android.com/reference/android/os/Parcel#dataSize()
| version = int; | ||
| protocol extension flags = int; | ||
| num bytes = int; | ||
| num bytes = long; |
There was a problem hiding this comment.
Oh good catch, sorry about that!
L73-java-binderchannel/wireformat.md
Outdated
| included. | ||
| * FLAG_MESSAGE_DATA_IS_PARCELABLE (0x40) - Indicates the message is a parcelable | ||
| object. | ||
| * FLAG_MESSAGE_DATA_IS_PARTIAL (0x80) - Indicates the message is partial and the receiver should continue reading. |
There was a problem hiding this comment.
Proposed change to make this clearer:
Where a message doesn't fit into a single transaction, the message will be sent in multiple transactions with this bit set on all but the final transaction of the message.
L73-java-binderchannel/wireformat.md
Outdated
|
|
||
| ## Flow Control | ||
|
|
||
| Due to the limited binder buffer size of 1MB, BinderTransport now supports flow control, aiming to keep use of the process transaction buffer to at most 128k. Each transaction we send adds to an internal count of unacknowledged outbound data (here the count refers to the "data size" of the parcels). If that exceeds 128k, we’ll stop sending transactions until we receive an acknowledgement message from the transport peer. Each transport sends an acknowledgement for each 16k received, which should avoid blocking the transport most of the time. |
There was a problem hiding this comment.
"now supports flow control" -> "supports transport-level flow control"
The reason I say this is that we still need to support real stream-level flow control separately.
L73-java-binderchannel/wireformat.md
Outdated
|
|
||
| Due to the limited binder buffer size of 1MB, BinderTransport now supports flow control, aiming to keep use of the process transaction buffer to at most 128k. Each transaction we send adds to an internal count of unacknowledged outbound data (here the count refers to the "data size" of the parcels). If that exceeds 128k, we’ll stop sending transactions until we receive an acknowledgement message from the transport peer. Each transport sends an acknowledgement for each 16k received, which should avoid blocking the transport most of the time. | ||
|
|
||
| For message larger than the flow control window size, the transport can choose to split it into multiple chunks using the FLAG_MESSAGE_DATA_IS_PARTIAL flag. |
There was a problem hiding this comment.
Let's move this paragraph to a section above Flow Control, called "Large Messages".
Message splitting is only indirectly related to flow control, so including this here is kind of "mixing concerns".
You can say that we limit the amount of message data sent in a single transaction to 16k. Messages larger than that will be sent in multiple sequential transactions, with all but the last transaction having FLAG_MESSAGE_DATA_IS_PARTIAL set.
2d5b172 to
7bf3001
Compare
|
nit: 128k -> 128KB. 16k -> 16KB |
Done. |
L73-java-binderchannel/wireformat.md
Outdated
|
|
||
| ## Flow Control | ||
|
|
||
| Due to the limited binder buffer size of 1MB, BinderTransport supports |
There was a problem hiding this comment.
Consider: "Due to the limited binder buffer size of 1MB" -> "Due to Android's limited per-process transaction buffer of 1MB"
Adds a bit more context and makes it clear this buffer size is out of our control.
There was a problem hiding this comment.
Done. Thanks for the review and suggestions!
The flow control mechanism is specified in the internal document but was not included in this proposal. Also, both documents didn't contain the description of the flag
FLAG_MESSAGE_DATA_IS_PARTIAL, which is crucial when breaking larger message into smaller chunks for flow control purposes.This PR copies the description of flow control mechanism in the internal document to the proposal, and explicitly introduce
FLAG_MESSAGE_DATA_IS_PARTIALand its usage. Additionally, thenum bytesfield inACKNOWLEDGE_BYTESrequests should be of typelong(64 bits) instead ofint(32 bits) judging from the implenmentation.