[ https://issues.apache.org/jira/browse/KAFKA-4846?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15897013#comment-15897013 ]
Ismael Juma commented on KAFKA-4846: ------------------------------------ Thanks for the report. There are a number of places in the producer where allocations are performed. If the aim is reuse objects and avoid new allocations, I think this needs to be investigated more thoroughly. We pass byte arrays to the public partitioner interface, for example. And we allocate other instances like TopicPartition and Deque. Any public API changes in Kafka require a KIP: https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Improvement+Proposals My take is that for something like this, it may be better to experiment on a fork to figure out the extent of the changes required before proposing the KIP. Before doing that, it may also be a good idea to send an email to the mailing list to gauge interest. Because if the changes turn out to be too complex for the benefit, people may feel that this should be done as an external client. > Use KafkaProducer without allocating a new ProducerRecord for each message > sent > ------------------------------------------------------------------------------- > > Key: KAFKA-4846 > URL: https://issues.apache.org/jira/browse/KAFKA-4846 > Project: Kafka > Issue Type: Improvement > Components: producer > Affects Versions: 0.10.2.0 > Reporter: Mikael Ståldal > > The KafkaProducer API requires you to allocate a new ProducerRecord for each > record sent. This is unfortunate since some application wants to reduce > object allocations to minimize GC work. This would be useful for Log4j to > allow [garbage free > logging|https://logging.apache.org/log4j/2.x/manual/garbagefree.html] in its > [Kafka > appender|https://logging.apache.org/log4j/2.x/manual/appenders.html#KafkaAppender]. > This could be solved by adding a new method with unrolled arguments to > KafkaProducer, like this: > {code} > Future<RecordMetadata> send(String topic, Integer partition, Long timestamp, > K key, V value); > {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)