orpiske commented on pull request #428: URL: https://github.com/apache/camel-kafka-connector/pull/428#issuecomment-688608723
> Hi @orpiske great work! Thanks! And thanks for the review! > > I was wondering which one of the contributions is predominant: better handling the remaining time or returning `null` if there are no results. The biggest gain is related to avoiding the busy spin. On the previous code we were returning immediately from the [receiveNoWait](https://github.com/apache/camel-kafka-connector/blob/036cb9cd3053d71e4f1bb7e33abdd0bde013ee8d/core/src/main/java/org/apache/camel/kafkaconnector/CamelSourceTask.java#L129) and so the loop was running thousands of time per poll. The change replaces the busy spin with a direct call to the receive, blocking for at most `maxPollDuration`. > > Do you mind, since you already have the performance tests at hand, doing a quick comparison towards just returning `null` if the result set is empty, like: [valdar@2edcfc0](https://github.com/valdar/camel-kafka-connector/commit/2edcfc079134ec2742cac8e5fa625170f4141373) I tried with returning the null as well. I have a flame graph with that test with [null available here](http://angusyoung.org/arquivos/tmp/profile-previous-with-null.svg). It doesn't seem to affect the performance, but I changed it nonetheless because that way it complies with the [connect API](https://github.com/apache/kafka/blob/trunk/connect/api/src/main/java/org/apache/kafka/connect/source/SourceTask.java#L46-L60). ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org