-
Notifications
You must be signed in to change notification settings - Fork 869
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
Natively support Memory<byte> #2311
base: master
Are you sure you want to change the base?
Conversation
|
There seems to be no progress on either of the several approaches to reduce allocations on the publishing side of Kafka. All of them are stuck at the review phase. We are affected by the issue as well and would really like to see how we can push this topic so that it finally gets the attention it deserves. @verdie-g Did you end up forking the project and adding your changes? |
We used a fork with #2219 just to confirm the important performance benefits but we were not ready to maintain a fork. We are still waiting for a review on that PR. |
f0a45e6
to
79bb726
Compare
🎉 All Contributor License Agreements have been signed. Ready to merge. |
There are many PRs open aiming to extend the API to allow low allocation produce but they all have some caveats:
Span
but given the constraints of that type, it means creating a whole new set of API.IBufferWriter
instead, which unlikebyte[]
orSpan
, supports non-contiguous memory, kind of likeStream
but it enables a lof of ways to reduce allocations. I don't thinkIBufferWriter
is ideal here because in the end, a continuous memory buffer is expected for both the key and value. Also, the PR is introducing several breaking changes.ArraySegment
propose to supportArraySegment
which does not break the API and fixes the original problem. Though it would prevent the use ofMemory<byte>
which is the preferred type when dealing with contiguous memory whenSpan<byte>
can't be used. This type is for example used in Stream.WriteAsync, Socket.SendAsync, and also in MemoryPool.Rent.Instead of adding a third type of serializer (after
ISerializer
andIAsyncSerializer
), this PR makes a special case forMemory<byte>
(andReadOnlyMemory<byte>
) to by pass the serializers and directly useMessage.Value
orMessage.Key
.Closes #1238.