confluentinc / confluent-kafka-dotnet

Confluent's Apache Kafka .NET client
https://github.com/confluentinc/confluent-kafka-dotnet/wiki
Apache License 2.0
71 stars 863 forks source link

SerializationContext #1238

Open Severus1992 opened 4 years ago

Severus1992 commented 4 years ago

Hello! You are planning a transition to a new Serialization context with IBufferWritter and DeserializationContext with ReadOnlySequence for zero-allocation ?

mhowlett commented 4 years ago

we aren't planning to prioritize this in the near future. if you have a specific recommendation, feel free to open a PR to demonstrate the suggested API. this would be a breaking change, and would require a version bump to 2.0.

nmosafi commented 1 year ago

Given confluent-kafka-dotnet is wrapping librdkafka I am not sure how feasible this suggestion is.

An approach which could work would be to change ISerializer and IAsyncSerializer to return ArraySegment<byte> rather than byte[]. This would at least allow apps to use pooled arrays or circular buffers, to achieve something closer to zero-allocation serialization when publishing to Kafka. The ArraySegment can easily map to a call to SafeKafkaHandle.Produce which accepts an array, an offset and a length