Skip to content

KAFKA-2654: optimize unnecessary poll(0) away#315

Closed
ymatsuda wants to merge 1 commit into
apache:trunkfrom
ymatsuda:less_poll_zero
Closed

KAFKA-2654: optimize unnecessary poll(0) away#315
ymatsuda wants to merge 1 commit into
apache:trunkfrom
ymatsuda:less_poll_zero

Conversation

@ymatsuda

Copy link
Copy Markdown
Contributor

@guozhangwang
This change aims to remove unnecessary consumer.poll(0) calls.

  • once after some partition is resumed
  • whenever the size of the top queue in any task is below BUFFERED_RECORDS_PER_PARTITION_CONFIG

@guozhangwang

Copy link
Copy Markdown
Contributor

I feel the second condition is still too restrictive: BUFFERED_RECORDS_PER_PARTITION_CONFIG is used to pause a certain partition and hence is usually large, probably we can define another config for a lower-threshold?

Also could you change the PR title with this Kafka ticket?

https://issues.apache.org/jira/browse/KAFKA-2654

I think it is not a minor issue and hence better be crediting as a major contribution.

@ymatsuda

Copy link
Copy Markdown
Contributor Author

The second condition checks only the top queue. It means that, if the top queue has records more than BUFFERED_RECORDS_PER_PARTITION_CONFIG, we may not poll records even if there are queues with sizes below BUFFERED_RECORDS_PER_PARTITION_CONFIG. This mechanism is orthogonal to the secondary threshold you are talking about.

@ymatsuda ymatsuda changed the title MINOR: optimize unnecessary poll(0) away KAFKA-2654: optimize unnecessary poll(0) away Oct 15, 2015
@guozhangwang

Copy link
Copy Markdown
Contributor

I see, that is right. The second condition is actually similar to the first one but just "pre-fetch" with one iteration earlier. LGTM.

@asfgit asfgit closed this in c50d39e Oct 15, 2015
@ymatsuda
ymatsuda deleted the less_poll_zero branch October 26, 2015 21:15
efeg added a commit to efeg/kafka that referenced this pull request Jan 29, 2020
davide-armand pushed a commit to aiven/kafka that referenced this pull request Dec 1, 2025
jeqo added a commit to aiven/kafka that referenced this pull request Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants