Skip to content
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

Please provide efficient (zero alloc) alternative to IStateSerializer #730

Open
mkosieradzki opened this issue Jul 22, 2018 · 2 comments
Open
Assignees

Comments

@mkosieradzki
Copy link
Contributor

Please provide an efficient (zero alloc) alternative to IStateSerializer - allowing to read and write to non-contiguous memory.

public interface IStateSerializer2<T>
{
  T Read(ReadOnlySequence<byte> sequence);
  T Read(T baseValue, ReadOnlySequence<byte> sequence);
  void Write(T value, IBufferWriter<byte> binaryWriter);
  void Write(T baseValue, T targetValue, IBufferWriter<byte> binaryWriter);
}

Both structures ReadOnlySequence<byte> and IBufferWriter<byte> have wide compatibility (.NET Standard 1.1) and allow to avoid unnecessary allocations and allow to use Spans. They are perfect fit for integration with unmanaged code.

I intend to use it with my span-based protocol buffers re-implementation described here: protocolbuffers/protobuf#3431

@MedAnd
Copy link

MedAnd commented Jul 23, 2018

@mkosieradzki - any chance you'll be nuget-ing your span-based protocol buffers re-implementation?

@mkosieradzki
Copy link
Contributor Author

@MedAnd First I will try to get it to the main repo (at least as a pre-release) - there is some hope, because it will be probably used for gRPC server. Meanwhile I will try to implement an alternative standalone gRPC middleware. If the process will be very slow or I would be unable to get my PRs accepted I will need to create separate nuget packages for both protobuf and gRPC-middleware.

@gkhanna79 gkhanna79 transferred this issue from microsoft/service-fabric-issues Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants