tower-grpc icon indicating copy to clipboard operation
tower-grpc copied to clipboard

Avoid cloning for parameter in RPC call.

Open agend opened this issue 5 years ago • 7 comments

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 avatar Jun 06 '19 13:06 agend

@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 avatar Jun 06 '19 14:06 olix0r

@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 avatar Jun 06 '19 14:06 agend

@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.

olix0r avatar Jun 06 '19 15:06 olix0r

@danburkert wdyt? At least we could have some way to configure prost-build to use Bytes for byte fields?

carllerche avatar Jun 06 '19 16:06 carllerche

FYI there is a draft PR up in prost now for bytes and bytesstring usage which may be helpful.

LucioFranco avatar Jun 06 '19 19:06 LucioFranco

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 avatar Jun 07 '19 15:06 danburkert

@danburkert just checking in, is there some work going on or it's stalled? Thanks!

kanekv avatar Nov 25 '19 06:11 kanekv