New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: PrepareMsg API to more easily parallelize serialization #2432
Comments
This would require updating the |
We can do this without changing Lines 670 to 684 in e441557
...or add a new key/value in the context, but this one seems fine to extend. An interceptor could mask this context completely, but that should be rare, and there are limits to what we can do given that we can't add methods to |
I think a good idea is to do the following Change rpcInfo to:
Following that, we will have to change the implementation of Since we can not add methods to An alternate implementation is as follows :
This would ensure that every stream that extends |
This is done for the sending side. A similar optimization could be done on the receiving side, too. |
@prannayk is it possible to make this available for |
doing something like #3480 solved my problem at least. But I'm completely new to this codebase, can someone guide me how should I proceed with this? Like which kinda of testing would make sense for this? Or what would make sense for the |
If the time to serialize and compress a message is less than the time to transmit it, a single stream is capable of saturating a network connection. This is because, in grpc-go, the N+1th message can be serialized and compressed while the Nth message is being transmitted. However, compression is usually a slow process that results in a small amount of data which can be quickly transmitted, so this is not usually the case with compression enabled. References: #1879, #2355.
We would like to separate the encoding and transmission steps so that users are able to perform multiple encodes simultaneously and take advantage of system parallelism.
Proposed API:
If a
PreparedMsg
is passed toSendMsg
,SendMsg
will use thePreparedMsg
's internal buffer to send the message on the stream, bypassing the marshal and compress steps.This API, as opposed to
func NewPreparedMsg(msg interface{}) PreparedMsg
, would allow users to re-use a PreparedMsg, and may save allocations of internal buffers.The text was updated successfully, but these errors were encountered: