KIP-872 — Add Serializer#serializeToByteBuffer() to reduce memory copying
Accepted ClientProducer
Adds Serializer#serializeToByteBuffer() as a default method returning ByteBuffer, enabling zero-copy serialization for types backed by ByteBuffer and eliminating the intermediate byte[] allocation and wrapping in KafkaProducer#doSend(). The current path always allocates a byte[], wraps it in a ByteBuffer, then writes it into MemoryRecordsBuilder, incurring unnecessary heap pressure for ByteBuffer-based payloads.
Details
| Author | LinShunKang |
| Status | Accepted |
| JIRA | KAFKA-14945 |
| Wiki | View on Apache Wiki |
| Created | 2022-09-25 |
| Last Modified | 2023-06-21 |
Explore how this KIP affects the Kafka protocol in the Protocol Explorer, or see the full KIP database.