gRPC Serialization Trait and grpc::Slice.

89 views
Skip to first unread message

Waqas Alam

unread,
Jun 17, 2022, 1:58:14 AM6/17/22
to grpc.io
Hi,
I'm using C++ gRPC Serialization Trait to encode gRPC messages using zero copy in gRPC unary API. Each message has a vector of buffers where each buffer is passed to grpc::Slice and there is no need to copy the buffer. I was wondering if there is something interesting I can do on the receive side ? What I have observed is that gRPC doesn't keep any state for the slices and data is received in chunks of size 8192 which is GRPC_TCP_DEFAULT_READ_SLICE_SIZE.  The issue I have is if total size of the all the buffers in a message is greater than 8192 a buffer may overlap two or more slices. This can happen for subsequent slices as well so currently I have to copy all the slices into a single slice or copy the buffer which extends over multiple slices. If there was a way to limit number of buffers to a single slice they can share the underneath  memory of a single slice and also avoid the copy operation. Just curious if current gRPC API provides such a capability.  

thanks

Mark D. Roth

unread,
Jun 22, 2022, 1:52:18 PM6/22/22
to Waqas Alam, grpc.io
Unfortunately, we don't currently have any support for this kind of zero-copy read on the receiving side.  In the long run, we have some ideas about how we'd like to support this kind of thing, but we haven't had time to turn our attention to this yet, so we have no concrete plan or ETA yet.  But I would expect that we will eventually add some APIs to support this kind of thing.

Note that gRPC does not provide any guarantee that received messages will show up in any particular chunk size.  You may happen to be seeing 8192 bytes right now, but that's highly dependent upon the server application, the network, proxies, encryption software, and a bunch of other factors, so what you're seeing right now could change at any time.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/5c5dbe60-6b22-48b8-b31d-8435f3117727n%40googlegroups.com.


--
Mark D. Roth <ro...@google.com>
Software Engineer
Google, Inc.
Reply all
Reply to author
Forward
0 new messages