Skip to content
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

Add an optional fast checker to (*partitionConsumer).responseFeeder #933

Merged
merged 3 commits into from
Sep 12, 2017

Conversation

wmille
Copy link
Contributor

@wmille wmille commented Aug 18, 2017

Add a ticker in (*partitionConsumer).responseFeeder to frequently check for
messages before starting the timeout timer. Using the fast checker significantly
reduces the number of timer function calls when timeouts are infrequent.

Add a ticker in (*partitionConsumer).responseFeeder to frequently check for
messages before starting the timeout timer. Using the fast checker significantly
reduces the number of timer function calls when timeouts are infrequent.
@eapache
Copy link
Contributor

eapache commented Aug 21, 2017

Interesting PR, thanks for looking at performance here. Do you have any benchmarks or profiles showing the call to expiryTimer.Reset as a particular bottleneck? In our experience it's usually quite overshadowed by the latency of the network, and the cost of whatever processing the consuming code actually does with the message.

I'm also a bit concerned by the complexity of the implementation here. Have you considered just converting the expiryTimer itself into a ticker? That would remove the need to maintain two channels and switch back and forth, at the cost of decreasing the accuracy of the timeout even further (to between MaxProcessingTime and 2 * MaxProcessingTime), but accuracy is basically irrelevant as long as it still prevents the consumer from getting stuck entirely.

@wmille
Copy link
Contributor Author

wmille commented Aug 22, 2017

go tool pprof shows about 20% of total program CPU time being spent in timer functions ((*Timer).Reset and (*Timer).Stop) called from (*partitionConsumer).responseFeeder.

We considered converting the expiryTimer into a ticker but thought that the loss of accuracy would be an issue. I could change the implementation to use that logic if the loss of accuracy would be acceptable.

@eapache
Copy link
Contributor

eapache commented Aug 22, 2017

Ya, I think that would be fine as long as we're clear about it in the documentation. The implementation will definitely be a lot easier to follow.

@eapache
Copy link
Contributor

eapache commented Aug 22, 2017

To clarify a little further: the timer is already very inaccurate because of the way it interacts with the buffer size of the messages channel (you could, in theory, get accuracy by setting the buffer size to 0, but I don't know of anybody who does nor can I imagine a use case for it).

Given this, I would be OK with just switching to the fast-checker and not adding a configuration option. Thoughts?

@wmille
Copy link
Contributor Author

wmille commented Aug 22, 2017

That makes sense. The configuration option was just left in because this change would technically change the timeout behavior (even though it is already very inaccurate as you described). I'll go ahead and make that change.

@wmille wmille force-pushed the timer_performance branch from e964019 to 9112d76 Compare August 22, 2017 19:34
@eapache
Copy link
Contributor

eapache commented Sep 12, 2017

Thanks!

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.

3 participants