On-Demand Scalable Timer Wheel for CPU Efficiency
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
The continuous operation of timer wheels in computing devices leads to unnecessary CPU usage and battery drain when there are no timers to service, and the use of global locks can introduce bottlenecks and performance slowdowns.
Innovation Solution
Implementing an on-demand scalable timer wheel that dynamically starts and stops based on the presence of active timers, using internal lists and atomic counters to manage timers without a global lock, allowing the timer wheel to suspend execution when all timers are serviced and reactivate only when new timers are added.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If the timer wheel continuously wakes up and checks for timers in each time slot, then timers can be serviced promptly, but CPU time and battery life are unnecessarily consumed when no timers are present
Solution Approach 1:
The timer wheel transitions from a static continuous operation mode to a dynamic mode where it can be suspended when no timers are present. The system dynamically adjusts its operation state based on the presence or absence of timers, suspending the timer wheel execution when the timer count reaches zero and resuming when new timers are added, thereby eliminating unnecessary CPU wake-ups and battery consumption.
2Stability of the object's composition
If a global lock is used on the timer wheel to regulate timer state, then timer wheel state consistency is maintained, but performance bottlenecks and slowdowns occur due to delayed lock acquisition
Solution Approach 1:
The global lock mechanism is completely removed from the timer wheel implementation. Instead of using a global lock to protect timer wheel state, the patent employs per-time-slot data structures with atomic operations and memory barriers to ensure consistency. This extraction of the global lock eliminates the bottleneck and performance slowdowns while maintaining state consistency through finer-grained synchronization mechanisms.
3Use of energy by moving object
If the timer wheel is suspended when void of timers, then CPU resources are freed for other tasks, but the timer wheel must be reactivated when new timers are added
Solution Approach 1:
The system implements a feedback mechanism where the timer wheel's operation state is continuously monitored based on the number of active timers. When the timer count reaches zero, the timer wheel is suspended and a flag is set. When new timers are added, the flag is checked and the timer wheel is reactivated. This feedback loop ensures efficient resource utilization while automatically managing the complexity of activation and suspension states.
Data Source
Figure 1
Figure 2
Figure 3
AI summary
Various embodiments enable on-demand scaling of a timer wheel. Some embodiments dynamically start and stop a timer wheel based, at least in part, on whether the timer wheel has any associated active timers. In some cases, the timer wheel is suspended when all associated active timers have been serviced. Alternately or additionally, the timer wheel is re-activated upon associating one or more active timers in need of service to the timer wheel. Various embodiments enable addition and removal of timer(s) to the timer wheel and/or various time slots associated with the timer wheel without using a global lock associated with the timer wheel.