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

Add a new type of Serializer for supporting zero allocation scenarios #2177

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on Jan 22, 2024

  1. Add a new type of Serializer for supporting zero allocation scenarios

    Right now `ISerializer` and `ISerializerAsync` are forced to allocate a new array for every message which is sent. For a high throughput application we'd like to avoid allocating large amounts of memory.
    
    The API exposed by librdkafka supports buffer reuse as it accepts a length and offset alongside each byte array, however this is not exposed by the serialization framework in Kafka dotnet.
    
    The simplest approach here is to allow `ArraySegment<byte>` to be returned by the serializer rather than `byte[]`, however changing all serializers to return `ArraySegment<byte>`` would surely be a large breaking change. So instead I decided to implement this as a new type of serializer.
    nmosafi committed Jan 22, 2024
    Configuration menu
    Copy the full SHA
    c5c0758 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e3d92d1 View commit details
    Browse the repository at this point in the history