-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
C# MergeFrom ReadOnlySpan with no allocations #7885
Comments
The issue with my solution is that the CodedInputStream eventually hits the state.sizelimit, so i have to allocate a new one every ~2GB of data. A native solution that does M.MergeFrom(ReadOnlySpan) without allocating any CodedInputStream would be great. |
Currently there is
There is also a MergeFrom variant of this method, but that one is internal.
Does that satisfy your needs? |
@jtattermusch Thank you for that. Unfortunately no it does not as that API allocates the holding proto. My goal is to reuse the proto and also not allocate the CIS. |
@MaximGurschi alright, so you'd basically need a public API for msg.MergeFrom(ReadOnlySequence data) (something along the lines of the latter internal method I posted), is that correct? |
@jtattermusch Precisely :) |
Feel free to come up with a PR that proposes the addition of new public method then? |
@jtattermusch it seems like it would still be useful to have overloads that take ReadOnlySpan, as sometimes that's what you're given. For instance, Confluent.Kafka's IDeserializer provides a ReadOnlySpan, which would then have to be copied to the heap to use the ReadOnlySequence overload :/
Is there something I'm missing that would allow |
Adding overloads that parse directly from FTR see
Feel free to propose a new public API for parsing from ReadOnlySpan<> and open a pull request (note that there are some other enhancement requests around the newly added APIs - please check the github issues for them first). |
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment. This issue is labeled |
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it. This issue was closed and archived because there has been no new activity in the 14 days since the |
Hi,
With the latest release of Grpc.Tools, we are now able to execute code that writes the serialized message directly to Span without incurring allocations. This is based on IBufferMessage. Thank you for that release!
My questions is what is the way to achieve the reverse process? Specifically without allocating a CodedInputStream or any other heap based objects. Is there (or are the plans for) an API that can help us achieve the following:
I have been using a custom solution to achieve the above steps but it involves subclassing Stream and a buffer copy to a preallocated buffer. If there were to be a native solution to achieve the equivalent of IMessage.MergeFrom(ReadOnlySpan) without additional allocation then that would help get rid of the workaround code.
The text was updated successfully, but these errors were encountered: