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 timer performance #240

Merged
merged 3 commits into from
Sep 2, 2024
Merged

Improve timer performance #240

merged 3 commits into from
Sep 2, 2024

Conversation

s-ludwig
Copy link
Member

This removes any GC allocations from the timer module and employs a hierarchical timing wheels based approach to ensure a timer performance doesn't degrade excessively when large numbers of timers are active. When many concurrent timeouts or sleeps are involved, this can lead to tenfold improvements in required CPU time.

Ensures that pointers to slots stay valid, allowing to avoid the m_timers map in the future.
Uses timer slot pointers directly as IDs. The validation counter field is used to ensure that stale timer IDs do not affect reused timer slots.
@s-ludwig s-ludwig requested a review from l-kramer August 31, 2024 15:13
Leads to heavy performance improvements in various scenarios involving many timers, partially benefiting from the hierarchical nature of the timing wheels structure and partially by avoiding the quadratic asymptotic run time of the timer queue approach (for each timer, the queue needs to be traversed linearly to find the insertion place).
@s-ludwig s-ludwig merged commit 4b76e58 into master Sep 2, 2024
23 checks passed
@s-ludwig s-ludwig deleted the timing_wheels branch September 2, 2024 13:46
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