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

Improve the performance of expireTimeouts() in HashedWheelTimer #12886

Closed
needmorecode opened this issue Oct 12, 2022 · 1 comment
Closed

Improve the performance of expireTimeouts() in HashedWheelTimer #12886

needmorecode opened this issue Oct 12, 2022 · 1 comment

Comments

@needmorecode
Copy link
Contributor

The original logic relies on a variable remainingRounds and in order to maintain it, all timeouts in the bucket have to be traversed.

In fact, the complete traversing of the linked list is not necessary.

My idea is to introduce a new variable currRound which represent the current round of the timer, and execRound for the execution round of each timeout. currRound is added by 1 when the tick starts a new round. Then for each timeout, we compare currRound and execRound to determine if the task should be executed, and break the loop once currRound < execRound.

By this means, we can reduce the number of traversed nodes, and the performance would be especially improved when the node number is large.

@needmorecode
Copy link
Contributor Author

needmorecode commented Oct 12, 2022

I made a PR in #12888

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

No branches or pull requests

1 participant