tower-grpc
tower-grpc copied to clipboard
Avoid cloning for parameter in RPC call.
I'm developing distributed storage system. There is a place in code where I send multiple requests to nodes in cluster to store replicas. Now I have to clone data buffer to do this in parallel. It would be great to find approach to avoid cloning as data buffer could be significant in size. https://github.com/qoollo/bob/blob/master/src/core/bob_client.rs#L75 buffer is immutable and something like Arc would be enough.
@agend is BobData
a protobuf bytes
type? Perhaps we could use the bytes crate to represent this type to facilitate shared access to the underlying memory?
@olix0r Yes. https://github.com/qoollo/bob/blob/master/proto/bob.proto#L33
bytes crate looks nice for this purpose. But to chage this do we need to change https://github.com/danburkert/prost ?
@agend I think that's correct; but I imagine prost users would generally benefit from this, so we may want to propose a breaking change.
@danburkert wdyt? At least we could have some way to configure prost-build to use Bytes
for byte fields?
FYI there is a draft PR up in prost now for bytes and bytesstring usage which may be helpful.
Yep, this has always been on the roadmap for prost
, tracked in danburkert/prost#31. @nrc put up a draft PR just recently with an implementation at danburkert/prost#190, so it may be landing sooner rather than later!
@danburkert just checking in, is there some work going on or it's stalled? Thanks!